Skip to contentSkip to conversation

remove unneeded ip6tables-save source/destination address output

PATCH In review Daniel De Graaf 2 participants 2 messages Dec 2, 2006 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove unneeded ip6tables-save source/destination address output

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ip6tables-save outputs the source and destination IPs when it is not needed. This
is caused by an incorrectly copied check from iptables-save. Example output:
- -A INPUT -s ::/0 -d ::/0 -i lo -j ACCEPT instead of just -A INPUT -i lo -j ACCEPT

This patch will not output the address if the mask length is zero.

- - Daniel De Graaf

Index: ip6tables-save.c
===================================================================
- --- ip6tables-save.c (revision 6699)
+++ ip6tables-save.c (working copy)
@@ -125,7 +125,7 @@

        char buf[51];
        int l = ipv6_prefix_length(mask);

- - if (!mask && !ip)
+ if (l == 0)

                return;
 
        printf("%s %s%s",

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFcM3DZz9quLVV3/MRAuYSAJ9wUCXr8yEiClPeuVfANBISlzBGTACffYHh dFqNciiAzKuvSTw7pXV2cAA=
=Ssso
-----END PGP SIGNATURE-----

#1 lore raw
Quoted 16 lines · Daniel De Graaf

ip6tables-save outputs the source and destination IPs when it is not needed. This
is caused by an incorrectly copied check from iptables-save. Example output:
-A INPUT -s ::/0 -d ::/0 -i lo -j ACCEPT instead of just -A INPUT -i lo -j ACCEPT

This patch will not output the address if the mask length is zero.

- Daniel De Graaf

Index: ip6tables-save.c
===================================================================

ip6tables-save.c (working copy) line 128

Quoted 5 lines
ip6tables-save.c (working copy) renamed from ip6tables-save.c (revision 6699) +1 -1
@@ -125,7 +125,7 @@
        char buf[51];
        int l = ipv6_prefix_length(mask);
 
-       if (!mask && !ip)
+       if (l == 0)

They both seem wrong since they ignore inversion (-s !0/0). I've committed this patch instead.

iptables-save.c +1 -1
Index: iptables-save.c
===================================================================
@@ -141,7 +141,7 @@
 /* print a given ip including mask if neccessary */
 static void print_ip(char *prefix, u_int32_t ip, u_int32_t mask, int invert)
 {
-	if (!mask && !ip)
+	if (!mask && !ip && !invert)
 		return;
 
 	printf("%s %s%u.%u.%u.%u",
ip6tables-save.c +1 -1
Index: ip6tables-save.c
===================================================================
@@ -125,7 +125,7 @@
 	char buf[51];
 	int l = ipv6_prefix_length(mask);
 
-	if (!mask && !ip)
+	if (l == 0 && !invert)
 		return;
 
 	printf("%s %s%s",