Skip to contentSkip to conversation

ip6tables: don't print out /128

PATCH In review Phil Oester 2 participants 4 messages Jun 22, 2013 – Jul 8, 2013 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip6tables: don't print out /128

Similar to how iptables does not print /32 on IPv4 addresses, ip6tables should not print out /128 on IPv6 addresses.

Phil

libxtables/xtables.c +5 -1
index ebc77b6..ef5bc07 100644
@@ -1597,7 +1597,11 @@ const char *xtables_ip6mask_to_numeric(const struct in6_addr *addrp)
 		strcat(buf, xtables_ip6addr_to_numeric(addrp));
 		return buf;
 	}
-	sprintf(buf, "/%d", l);
+	/* we don't want to see "/128" */
+	if (l == 128)
+		return "";
+	else
+		sprintf(buf, "/%d", l);
 	return buf;
 }
 
#1 lore raw

Hi Phil,

Quoted 2 lines · Phil Oester

Similar to how iptables does not print /32 on IPv4 addresses, ip6tables should not print out /128 on IPv6 addresses.

I just look at the source of old iptables releases (1.4.11) and it displays the /32 with iptables -L. I prefer if we restore that behaviour, ie. we get it back to display /32, for historial reasons.

#2 lore raw
Quoted 3 lines · Pablo Neira Ayuso

I just look at the source of old iptables releases (1.4.11) and it displays the /32 with iptables -L. I prefer if we restore that behaviour, ie. we get it back to display /32, for historial reasons.

That does not appear to be correct.

# ./iptables-multi main -V
iptables v1.4.10
# ./iptables-multi main -L foo  
Chain foo (0 references)
target     prot opt source               destination         
           all  --  1.2.3.4              anywhere
Quoted 1 line

From what I can tell, the comment

	/* we don't want to see "/32" */

has existed in the tree since at least 3/2000.

Phil

#3 lore raw
Quoted 16 lines · Phil Oester
Quoted 3 lines · Pablo Neira Ayuso

I just look at the source of old iptables releases (1.4.11) and it displays the /32 with iptables -L. I prefer if we restore that behaviour, ie. we get it back to display /32, for historial reasons.

That does not appear to be correct.

# ./iptables-multi main -V
iptables v1.4.10
# ./iptables-multi main -L foo  
Chain foo (0 references)
target     prot opt source               destination         
           all  --  1.2.3.4              anywhere
Quoted 5 lines

From what I can tell, the comment

	/* we don't want to see "/32" */

has existed in the tree since at least 3/2000.

You're right, I was looking at the wrong place in the code. I have applied this patch. Thanks.