-j ECN --ecn-tcp-remove seems to be mangling the TCP checksum...
Environment: x86, 2.4.19 kernel with NTP PPS, ipsec, and netfilter patch-o-matic patches (current CVS) installed. Monolithic kernel.
I have the current mangle rules installed:
bash-2.05b# iptables -n -t mangle -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination fix-ecn tcp -- 0.0.0.0/0 0.0.0.0/0 tcp flags:0x16/0x02
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
Chain fix-ecn (1 references)
target prot opt source destination ECN tcp -- 0.0.0.0/0 205.181.112.65 ECN TCP remove ECN tcp -- 0.0.0.0/0 205.152.54.6 ECN TCP remove ECN tcp -- 0.0.0.0/0 134.219.0.0/16 ECN TCP remove ECN tcp -- 0.0.0.0/0 64.14.140.109 ECN TCP remove
The fix-ecn chain is the beginning of a rule to cope with broken hosts (or, more commonly, firewalls) that do the wrong thing with ECN.
First, suppose I turn tcp_ecn on and try to telnet to some random web server:
bash-2.05b# echo 1 > /proc/sys/net/ipv4/tcp_ecn ; telnet 1.1.1.1 80
tcpdump -vvvx produces
01:50:26.819358 science.horizon.com.11047 > 1.1.1.1.www: SWE [tcp sum ok] 2541756082:2541756082(0) win 5840 <mss 1460,sackOK,timestamp 14279600 0,nop,wscale 0> (DF) [tos 0x10] (ttl 64, id 64770, len 60)
4510 003c fd02 4000 4006 1783 c023 6401
0101 0101 2b27 0050 9780 1eb2 0000 0000
a0c2 16d0 441d 0000 0204 05b4 0402 080a
00d9 e3b0 0000 0000 0103 0300Now I'll turn tcp_ecn off:
bash-2.05b# echo 0 > /proc/sys/net/ipv4/tcp_ecn ; telnet 1.1.1.1 80
01:50:55.077891 science.horizon.com.11051 > 1.1.1.1.www: S [tcp sum ok] 2563190821:2563190821(0) win 5840 <mss 1460,sackOK,timestamp 14282426 0,nop,wscale 0> (DF) [tos 0x10] (ttl 64, id 56991, len 60)
4510 003c de9f 4000 4006 35e6 c023 6401
0101 0101 2b2b 0050 98c7 3025 0000 0000
a002 16d0 2715 0000 0204 05b4 0402 080a
00d9 eeba 0000 0000 0103 0300Now I'll add the random host to the fix_ecn and try with ECN turned on:
bash-2.05b# iptables -t mangle -A fix-ecn -d 1.1.1.1 -p tcp -j ECN --ecn-tcp-remove
bash-2.05b# echo 1 > /proc/sys/net/ipv4/tcp_ecn ; telnet 1.1.1.1 80
01:52:20.662338 science.horizon.com.11058 > 1.1.1.1.www: S [bad tcp cksum bf40!] 2655433521:2655433521(0) win 5840 <mss 1460,sackOK,timestamp 14290984 0,nop,wscale 0> (DF) [tos 0x10] (ttl 64, id 41753, len 60)
4510 003c a319 4000 4006 716c c023 6401
0101 0101 2b32 0050 9e46 b331 0000 0000
a002 16d0 3c55 0000 0204 05b4 0402 080a
00da 1028 0000 0000 0103 0300Now I'll turn tcp_ecn off again:
bash-2.05b# echo 0 > /proc/sys/net/ipv4/tcp_ecn ; telnet 1.1.1.1 80
01:52:36.771155 science.horizon.com.11059 > 1.1.1.1.www: S [tcp sum ok] 2671050014:2671050014(0) win 5840 <mss 1460,sackOK,timestamp 14292595 0,nop,wscale 0> (DF) [tos 0x10] (ttl 64, id 60269, len 60)
4510 003c eb6d 4000 4006 2918 c023 6401
0101 0101 2b33 0050 9f34 fd1e 0000 0000
a002 16d0 2bed 0000 0204 05b4 0402 080a
00da 1673 0000 0000 0103 0300Notice the bad tcp checksum in the third case.
Is this a bug? The ipt_ECN.c file is
ipt_ECN.c,v 1.4 2002/08/05 19:36:51 laforge Exp
Thanks!
Quoted 2 lines
Is this a bug? The
ipt_ECN.cfile is
ipt_ECN.c,v 1.4 2002/08/05 19:36:51 laforge Exp
No it is not. Do the same with a remote host.
Send a ECNstripped packets to some other host, and tcpdump there. The checksum will be ok.
It is the problem with tcpdump getting a cloned copy of the packet, read the RR's FIXME notes in netfilter sources about it.
I noticed that too, once, and thought it's a checksum calculation bug.
Quoted 1 line
Thanks!
Regards,
Maciej Soltysiak