Skip to contentSkip to conversation

libipt_NETMAP: Avoid listing 32 bit mask and fix tests

PATCH In review Shivani Bhardwaj 3 participants 3 messages Jun 14, 2016 – Jun 17, 2016 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libipt_NETMAP: Avoid listing 32 bit mask and fix tests

(1) If subnet mask is unspecified with an IPv4 address, the rule lists as

iptables -I PREROUTING -t nat -j NETMAP --to to:1.2.3.4/32

Remove this and make the rule list as

iptables -I PREROUTING -t nat -j NETMAP --to to:1.2.3.4

(2) Fix the tests for NETMAP for IPv4.

Before this patch,

ERROR: line 3 (cannot find: iptables -I PREROUTING -t nat -j NETMAP --to 1.2.3.0/24)
ERROR: line 4 (cannot find: iptables -I PREROUTING -t nat -j NETMAP --to 1.2.3.4)

After this patch, no errors with tests were observed.

---
 extensions/libipt_NETMAP.c | 2 +-
 extensions/libipt_NETMAP.t | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
extensions/libipt_NETMAP.c +1 -1
index 4932c96..7c5d657 100644
@@ -76,7 +76,7 @@ static void NETMAP_print(const void *ip, const struct xt_entry_target *target,
 	bits = netmask2bits(a.s_addr);
 	if (bits < 0)
 		printf("/%s", xtables_ipaddr_to_numeric(&a));
-	else
+	else if (bits < 32)
 		printf("/%d", bits);
 }
 
extensions/libipt_NETMAP.t +2 -2
index 31924b9..de2bf8f 100644
@@ -1,4 +1,4 @@
 :PREROUTING,INPUT,OUTPUT,POSTROUTING
 *nat
--j NETMAP --to 1.2.3.0/24;=;OK
--j NETMAP --to 1.2.3.4;=;OK
+-j NETMAP --to 1.2.3.0/24;-j NETMAP --to  to:1.2.3.0/24;OK
+-j NETMAP --to 1.2.3.4;-j NETMAP --to  to:1.2.3.4;OK
Signature · 1 line
1.9.1
#1 lore raw

extensions/libipt_NETMAP.t line 4

Quoted 11 lines · Shivani Bhardwaj
extensions/libipt_NETMAP.t +2 -2
index 31924b9..de2bf8f 100644
@@ -1,4 +1,4 @@
 :PREROUTING,INPUT,OUTPUT,POSTROUTING
 *nat
--j NETMAP --to 1.2.3.0/24;=;OK
--j NETMAP --to 1.2.3.4;=;OK
+-j NETMAP --to 1.2.3.0/24;-j NETMAP --to  to:1.2.3.0/24;OK
+-j NETMAP --to 1.2.3.4;-j NETMAP --to  to:1.2.3.4;OK
                                          ^^^

Shivani, thanks for spotting this.

It seems 90becf12bd5 broke iptables-save.

maintainer
#2 lore raw
Quoted 14 lines · Pablo Neira Ayuso

extensions/libipt_NETMAP.t line 4

Quoted 11 lines · Shivani Bhardwaj
extensions/libipt_NETMAP.t +2 -2
index 31924b9..de2bf8f 100644
@@ -1,4 +1,4 @@
 :PREROUTING,INPUT,OUTPUT,POSTROUTING
 *nat
--j NETMAP --to 1.2.3.0/24;=;OK
--j NETMAP --to 1.2.3.4;=;OK
+-j NETMAP --to 1.2.3.0/24;-j NETMAP --to  to:1.2.3.0/24;OK
+-j NETMAP --to 1.2.3.4;-j NETMAP --to  to:1.2.3.4;OK
                                          ^^^
Quoted 3 lines

Shivani, thanks for spotting this.

It seems 90becf12bd5 broke iptables-save.

Right, sorry.
I'll submit a patch asap.