Skip to contentSkip to conversation

Byte order problem in libxt_conntrack.c

PATCH In review Tom Eastep 2 participants 2 messages Jul 6, 2011 – Jul 9, 2011 netfilter

lore
Share & tools
lore

Tom Eastep

author
#0 lore raw

PATCH 1/1 Byte order problem in libxt_conntrack.c

Using iptables 4.4.11.1, the following input:

-A lan-dmz -p 6 --dport 80 -m conntrack --ctorigdstport 8080 -d 70.90.191.125 -m conntrack --ctorigdst 172.20.1.254 -j ACCEPT

Results in this:

Chain lan-dmz (1 references)

 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            70.90.191.125        tcp dpt:80 ctorigdstport 36895 ctorigdst 172.20.1.254

Note that 8080 == 0x1f90 while 36895 == 0x901f.

The attached patch seems to resolve the issue.

-Tom

Signature · 4 lines
Tom Eastep        \ When I die, I want to go like my Grandfather who
Shoreline,         \ died peacefully in his sleep. Not screaming like
Washington, USA     \ all of the passengers in his car
http://shorewall.net \________________________________________________
libxt_conntrack.c renamed from libxt_conntrack.c.orig +4 -4
@@ -130,13 +130,13 @@
 	{.name = "ctexpire", .id = O_CTEXPIRE, .type = XTTYPE_UINT32RC,
 	 .flags = XTOPT_INVERT},
 	{.name = "ctorigsrcport", .id = O_CTORIGSRCPORT, .type = XTTYPE_PORTRC,
-	 .flags = XTOPT_INVERT},
+	 .flags = XTOPT_INVERT|XTOPT_NBO},
 	{.name = "ctorigdstport", .id = O_CTORIGDSTPORT, .type = XTTYPE_PORTRC,
-	 .flags = XTOPT_INVERT},
+	 .flags = XTOPT_INVERT|XTOPT_NBO},
 	{.name = "ctreplsrcport", .id = O_CTREPLSRCPORT, .type = XTTYPE_PORTRC,
-	 .flags = XTOPT_INVERT},
+	 .flags = XTOPT_INVERT|XTOPT_NBO},
 	{.name = "ctrepldstport", .id = O_CTREPLDSTPORT, .type = XTTYPE_PORTRC,
-	 .flags = XTOPT_INVERT},
+	 .flags = XTOPT_INVERT|XTOPT_NBO},
 	{.name = "ctdir", .id = O_CTDIR, .type = XTTYPE_STRING},
 	XTOPT_TABLEEND,
 };
#1 lore raw
Quoted 6 lines · Tom Eastep

Using iptables 4.4.11.1, the following input:

-A lan-dmz -p 6 --dport 80 -m conntrack --ctorigdstport 8080 -d 70.90.191.125 -m conntrack --ctorigdst 172.20.1.254 -j ACCEPT

Results in this:

Quoted 7 lines

Chain lan-dmz (1 references)

pkts bytes target     prot opt in     out     source               destination         
   0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            70.90.191.125        tcp dpt:80 ctorigdstport 36895 ctorigdst 172.20.1.254

Note that 8080 == 0x1f90 while 36895 == 0x901f.

The attached patch seems to resolve the issue.

Thanks, taken it in.

FTR, links to DUPLICATE candidates: http://bugs.debian.org/632804