ECN mangling
Hi,
Having run into problems with /proc/sys/net/ipv4/tcp_ecn being 1 for
Explicit Congestion Notification I first turned it off, and then found the kernel configuration options for modules to allow me to mangle it off per iptables rule.
After some bashing of head against desk I found the syntax that works
to add a rule:
iptables -t mangle -A OUTPUT -o eth1 -p tcp -d IP/32 --match ecn --ecn-ip-ect 0 -j ECN --ecn-tcp-remove
This does indeed cause the appropriate flags to get stripped from the packet. Without it I see things like:
07:31:40.610299 80.4.77.247.33917 > 212.250.5.117.80: SWE [tcp sum ok] 301537362:301537362(0) win 5840 <mss 1460,sackOK,timestamp 2075414 0,nop,wscale 0> (DF) (ttl 64, id 45892, len 60)
With it I now see:
07:32:02.470307 80.4.77.247.33919 > 212.250.5.117.80: S [bad tcp cksum bf40!] 322522142:322522142(0) win 5840 <mss 1460,sackOK,timestamp 2077600 0,nop,wscale 0> (DF) (ttl 64, id 65470, len 60)
and the packets never seem to do much. Of course once I'd added a few -v's to tcpdump as above I can see the problem "[bad tcp cksum bf40!]". It would seem that mangling the packet in this way is causing the tcp checksum to become invalid.
Is there something additional/different I should be doing in the
rules, or is this just a plain bug in the ECN modules?
-Ath
Signature · 4 lines
- Athanasius = Athanasius(at)miggy.org / http://www.miggy.org/
Finger athan(at)fysh.org for PGP key
"And it's me who is my enemy. Me who beats me up.
Me who makes the monsters. Me who strips my confidence." Paula Cole - MEQuoted 8 lines · Athanasius
iptables -t mangle -A OUTPUT -o eth1 -p tcp -d IP/32 --match ecn --ecn-ip-ect 0 -j ECN --ecn-tcp-remove
07:32:02.470307 80.4.77.247.33919 > 212.250.5.117.80: S [bad tcp cksum bf40!] 322522142:322522142(0) win 5840 <mss 1460,sackOK,timestamp 2077600 0,nop,wscale 0> (DF) (ttl 64, id 65470, len 60)
and the packets never seem to do much. Of course once I'd added a few -v's to tcpdump as above I can see the problem "[bad tcp cksum bf40!]". It would seem that mangling the packet in this way is causing the tcp checksum to become invalid.
I should have said this before. This is specifically using kernel
2.4.21-pre21, no additional patches, and iptables-1.2.7a as provided in Debian unstable (I grabbed the source the compiled and installed it on a Debian stable/woody/3.0 system).
Looking at latest CVS there doesn't seem to be any changes to the code
in net/ipv4/netfilter/ipt_ECN.c. Not being uptospeed with how the code all works it looks like it should be working:
89 if (diffs[0] != *tcpflags) {
90 diffs[0] = htons(diffs[0]) ^ 0xFFFF;
91 diffs[1] = htons(*tcpflags);
92 tcph->check = csum_fold(csum_partial((char *)diffs,
93 sizeof(diffs),
94 tcph->check^0xFFFF));
95 (*pskb)->nfcache |= NFC_ALTERED;
96
97 return 1;
98 }But it obviously isn't.
-Ath
Signature · 4 lines
- Athanasius = Athanasius(at)miggy.org / http://www.miggy.org/
Finger athan(at)fysh.org for PGP key
"And it's me who is my enemy. Me who beats me up.
Me who makes the monsters. Me who strips my confidence." Paula Cole - MEthere's a bug in that code: in the netfilter-devel mailing list a patch was posted:
Quoted 2 lines
90 diffs[0] = diffs[0] ^ 0xFFFF;
91 diffs[1] = *tcpflags;that does the job.
andrea
Quoted 18 lines · Athan
Looking at latest CVS there doesn't seem to be any changes to the code
innet/ipv4/netfilter/ipt_ECN.c. Not being uptospeed with how the code all works it looks like it should be working:89 if (diffs[0] != *tcpflags) { 90 diffs[0] = htons(diffs[0]) ^ 0xFFFF; 91 diffs[1] = htons(*tcpflags); 92 tcph->check = csum_fold(csum_partial((char *)diffs, 93 sizeof(diffs), 94 tcph->check^0xFFFF)); 95 (*pskb)->nfcache |= NFC_ALTERED; 96 97 return 1; 98 }But it obviously isn't.
-Ath
Quoted 8 lines · Andrea Rossato
there's a bug in that code: in the netfilter-devel mailing list a patch was posted:
Quoted 2 lines
90 diffs[0] = diffs[0] ^ 0xFFFF; 91 diffs[1] = *tcpflags;that does the job.
andrea
Thanks, that works, although I can't find any mention of it in the
netfilter-devel archive. I trust a patch is being pushed to Linus/whoever to get this fixed in mainstream kernels?
-Ath
Signature · 4 lines
- Athanasius = Athanasius(at)miggy.org / http://www.miggy.org/
Finger athan(at)fysh.org for PGP key
"And it's me who is my enemy. Me who beats me up.
Me who makes the monsters. Me who strips my confidence." Paula Cole - MEQuoted 2 lines · Athanasius
Thanks, that works, although I can't find any mention of it in the
netfilter-devel archive.
http://lists.netfilter.org/pipermail/netfilter-devel/2002-December/009989.html
Quoted 2 lines
I trust a patch is being pushed to
Linus/whoever to get this fixed in mainstream kernels?
I hope. It did not show up in 2.4.21-preX so far, though..
andrea