kernel crash
We recently have had trouble with kernel crashes on a Linux 2.4.20 box used as a NAT gateway. The machine is running Slackware 8.1 with a vanilla 2.4.20 kernel. The kernel configuration is attached. The message-log attachment contains the full dmesg output, as captured by a remote syslog server, as well as the last messages received before the box hung:
May 28 16:18:08 tog-wakko4 kernel: LIST_DELETE: ip_conntrack_core.c:303 `&ct->tuplehash[IP_CT_DIR_REPLY]'(f687fbc4) not in &ip_conntrack_hash [hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)]. May 28 16:18:52 tog-wakko4 kernel: LIST_DELETE: ip_conntrack_core.c:303 `&ct->tuplehash[IP_CT_DIR_REPLY]'(f687cd24) not in &ip_conntrack_hash [hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)]. May 28 16:18:52 tog-wakko4 kernel: LIST_DELETE: ip_conntrack_core.c:303 `&ct->tuplehash[IP_CT_DIR_REPLY]'(f687ce64) not in &ip_conntrack_hash [hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)].
What further information would be useful in tracking down this problem?
Quoted 1 line · Gordon Messmer
May 28 16:18:08 tog-wakko4 kernel: LIST_DELETE:
ip_conntrack_core.c:303
Quoted 3 lines
`&ct->tuplehash[IP_CT_DIR_REPLY]'(f687fbc4) not in
&ip_conntrack_hash[hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)].May 28 16:18:52 tog-wakko4 kernel: LIST_DELETE:
ip_conntrack_core.c:303
Quoted 3 lines
`&ct->tuplehash[IP_CT_DIR_REPLY]'(f687cd24) not in
&ip_conntrack_hash[hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)].May 28 16:18:52 tog-wakko4 kernel: LIST_DELETE:
ip_conntrack_core.c:303
Quoted 2 lines
`&ct->tuplehash[IP_CT_DIR_REPLY]'(f687ce64) not in
&ip_conntrack_hash[hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)].
what iptables statements are you running at startup?
i had a similar problem, i think, last summer due to _overlapping_ nat rules causing a race condition. i'm not sure anyone ever knew what to do about it, but i did find that tweaking some rules kept the bug from being triggered.
http://marc.theaimsgroup.com/?l=netfilter-devel&m=102750186506947&w=2
i used to use:
iptables -t nat -A POSTROUTING -j SNAT --to 64.192.31.41 iptables -t nat -A POSTROUTING -j SNAT --to 192.168.1.1 iptables -t nat -A POSTROUTING -j SNAT --to 127.0.0.1
and now i use something very similar to (now i have 3 ifs):
iptables -t nat -A POSTROUTING -j SNAT -o eth0 --to 64.192.31.41
iptables -t nat -A POSTROUTING -o eth1 -s 192.168.1.0/24 \ -j SNAT --to 192.168.1.1 iptables -t nat -A POSTROUTING -o eth2 -s 192.168.2.0/24 \ -j SNAT --to 192.168.2.1
i've formulated the opinion that the first set of rules would match a packet on multiple rules and mangle the packet more than once, while the new rule set only matches packets going certain directions, so a packet only matches one rule.
i think these multiple matches caused a race condition and hung the machine. does this make any sense to anyone?
the idea of these rules is to mangle the destination of a packet that came in on an interface and got forwarded back out the same interface. this allows a port forward to work from any network, even if it's the same network. here's my example:
iptables -t nat -A PREROUTING -p tcp \ --destination 64.192.31.41 --destination-port 2080 \ -j DNAT --to 192.168.1.2:80
with the SNATs above, this connection works:
192.168.1.2 -> 64.192.31.41:2080 -> 192.168.1.2:80
and return:
192.168.1.2 <- 64.192.31.41 <- 192.168.1.2:80if i only did the SNAT on the external ip, then the forward would only work when the connection came from the outside.
a connection from the intranet would:
192.168.1.2 -> 64.192.31.41:2080 -> 192.168.1.2:80
and return:
192.168.1.2 <- 192.168.1.2:80 the return path wouldn't match up and thus the packets were just lost.
Signature · 3 lines
____________________}John Flinchbaugh{______________________
| [email protected] http://www.hjsoft.com/~glynis/ |
~~Powered by Linux: Reboots are for hardware upgrades only~~Quoted 14 lines · Gordon Messmer
We recently have had trouble with kernel crashes on a Linux 2.4.20 box used as a NAT gateway. The machine is running Slackware 8.1 with a vanilla 2.4.20 kernel. The kernel configuration is attached. The message-log attachment contains the full dmesg output, as captured by a remote syslog server, as well as the last messages received before the box hung:
May 28 16:18:08 tog-wakko4 kernel: LIST_DELETE: ip_conntrack_core.c:303 `&ct->tuplehash[IP_CT_DIR_REPLY]'(f687fbc4) not in &ip_conntrack_hash [hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)]. May 28 16:18:52 tog-wakko4 kernel: LIST_DELETE: ip_conntrack_core.c:303 `&ct->tuplehash[IP_CT_DIR_REPLY]'(f687cd24) not in &ip_conntrack_hash [hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)]. May 28 16:18:52 tog-wakko4 kernel: LIST_DELETE: ip_conntrack_core.c:303
Quoted 4 lines
`&ct->tuplehash[IP_CT_DIR_REPLY]'(f687ce64) not in
&ip_conntrack_hash[hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)].What further information would be useful in tracking down this problem?
Beware that conntrack in kernel 2.4.20 has a serious bug caused by core kernel changes. Can you please try 2.4.21-rc or apply at least submitted/10_confirm_fix.patch from patch-o-matic and run the same thing again and see if it still happens?
It appears that as if the reply-tuple is modified after the conntrack has been added to the hashtable (shouldn't happen). The only place this modification could happen is in ip_conntrack_alter_reply() which is called from ip_nat_setup_info() which in turn is called from various places to set up NAT mappings. But I can't find a place where it's called for a connection that's already in the hashtable... And the IP_NF_ASSERT() in ip_conntrack_alter_reply() would have triggered unless the conntrack had already been deleted from the lists...
Which modules are you using?
Signature · 1 line
/Martin
Quoted 5 lines · Martin Josefsson
Beware that conntrack in kernel 2.4.20 has a serious bug caused by core kernel changes. Can you please try 2.4.21-rc or apply at least
submitted/10_confirm_fix.patchfrom patch-o-matic and run the same thing again and see if it still happens?
I've suggested the patch to the person responsible for the machine (I'm just helping him track this down).
Quoted 9 lines
It appears that as if the reply-tuple is modified after the conntrack has been added to the hashtable (shouldn't happen). The only place this modification could happen is in
ip_conntrack_alter_reply()which is called fromip_nat_setup_info()which in turn is called from various places to set up NAT mappings. But I can't find a place where it's called for a connection that's already in the hashtable... And theIP_NF_ASSERT()inip_conntrack_alter_reply()would have triggered unless the conntrack had already been deleted from the lists...
Possibly memory corruption, then?
Quoted 3 lines
Which modules are you using?
According to Mark:
lsmod
Module Size Used by Not tainted
ipt_MARK 856 1 (autoclean) ipt_LOG 3320 1 (autoclean) ipt_limit 1048 1 (autoclean) ipt_REJECT 2840 13 (autoclean) ipt_mark 536 1 (autoclean) iptable_mangle 2228 1 (autoclean) ip_nat_ftp 3696 0 (unused) ip_conntrack_ftp 4240 1 [ip_nat_ftp] ipt_state 632 0 (unused) ipt_multiport 728 0 (unused) ipt_esp 632 0 (unused) ipt_MASQUERADE 1944 1 iptable_filter 1736 1 iptable_nat 21176 2 [ip_nat_ftp ipt_MASQUERADE] ip_conntrack 28064 3 [ip_nat_ftp ip_conntrack_ftp ipt_state
ipt_MASQUERADE iptable_nat]ip_tables 13400 14 [ipt_MARK ipt_LOG ipt_limit ipt_REJECT
ipt_mark iptable_mangle ipt_state ipt_multiport ipt_esp ipt_MASQUERADE iptable_filter iptable_nat]
ip_gre 7584 0 (unused) sk98lin 113136 1 e1000 47980 1
Quoted 9 lines · Gordon Messmer
Quoted 5 lines · Martin Josefsson
Beware that conntrack in kernel 2.4.20 has a serious bug caused by core kernel changes. Can you please try 2.4.21-rc or apply at least
submitted/10_confirm_fix.patchfrom patch-o-matic and run the same thing again and see if it still happens?I've suggested the patch to the person responsible for the machine (I'm just helping him track this down).
Ok.
Quoted 1 line
Possibly memory corruption, then?
Can very well be a real bug, There have been reports of the same thing happening to UP machines running 2.4.21-rc kernels (which include the patch mentioned above, but I still think your friend should apply it)
I'll see if I can cook up some form of debugging-patch for this, it might help us track it down. Some way of reproducing it wouldn't hurt.
Does he still have the same problem if he removes ip_conntrack_ftp and ip_nat_ftp ?
Quoted 31 lines
Quoted 3 lines
Which modules are you using?
According to Mark:
lsmod
Module Size Used by Not taintedipt_MARK 856 1 (autoclean) ipt_LOG 3320 1 (autoclean) ipt_limit 1048 1 (autoclean) ipt_REJECT 2840 13 (autoclean) ipt_mark 536 1 (autoclean) iptable_mangle 2228 1 (autoclean) ip_nat_ftp 3696 0 (unused) ip_conntrack_ftp 4240 1 [ip_nat_ftp] ipt_state 632 0 (unused) ipt_multiport 728 0 (unused) ipt_esp 632 0 (unused) ipt_MASQUERADE 1944 1 iptable_filter 1736 1 iptable_nat 21176 2 [ip_nat_ftp ipt_MASQUERADE] ip_conntrack 28064 3 [ip_nat_ftp ip_conntrack_ftp ipt_state
ipt_MASQUERADEiptable_nat]ip_tables13400 14 [ipt_MARKipt_LOGipt_limitipt_REJECT
ipt_markiptable_mangleipt_stateipt_multiportipt_espipt_MASQUERADEiptable_filteriptable_nat]ip_gre 7584 0 (unused) sk98lin 113136 1 e1000 47980 1
Signature · 1 line
/Martin
Hi all,
Quoted 4 lines · Martin Josefsson
Beware that conntrack in kernel 2.4.20 has a serious bug caused by core kernel changes. Can you please try 2.4.21-rc or apply at least
submitted/10_confirm_fix.patchfrom patch-o-matic and run the same thing again and see if it still happens?
As I'm using kernel 2.4.20 and conntrack as well, I'm very interessted in this problem. I've just patched the kernel with 10_confirm_fix but have no chance to test it under load. Testing my software in a real-scenario on tuesday, I would be glad to hear if this patch fixes the problem or if I'm forced to update the kernel.
Best regards,
Eicke.