netfilter: conntrack: resched in nf_ct_iterate_cleanup
commitd93c6258ee4255749c10012c50a31c08f4e9fb16
authorFlorian Westphal <fw@strlen.de>
Wed, 20 Jan 2016 10:16:43 +0000 (20 11:16 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 31 Jan 2016 23:15:26 +0000 (1 00:15 +0100)
treebb2ca281b4a2467572b3541780a0b74088e75de3
parent53729eb174c1589f9185340ffe8c10b3f39f3ef3
netfilter: conntrack: resched in nf_ct_iterate_cleanup

Ulrich reports soft lockup with following (shortened) callchain:

NMI watchdog: BUG: soft lockup - CPU#1 stuck for 22s!
__netif_receive_skb_core+0x6e4/0x774
process_backlog+0x94/0x160
net_rx_action+0x88/0x178
call_do_softirq+0x24/0x3c
do_softirq+0x54/0x6c
__local_bh_enable_ip+0x7c/0xbc
nf_ct_iterate_cleanup+0x11c/0x22c [nf_conntrack]
masq_inet_event+0x20/0x30 [nf_nat_masquerade_ipv6]
atomic_notifier_call_chain+0x1c/0x2c
ipv6_del_addr+0x1bc/0x220 [ipv6]

Problem is that nf_ct_iterate_cleanup can run for a very long time
since it can be interrupted by softirq processing.
Moreover, atomic_notifier_call_chain runs with rcu readlock held.

So lets call cond_resched() in nf_ct_iterate_cleanup and defer
the call to a work queue for the atomic_notifier_call_chain case.

We also need another cond_resched in get_next_corpse, since we
have to deal with iter() always returning false, in that case
get_next_corpse will walk entire conntrack table.

Reported-by: Ulrich Weber <uw@ocedo.com>
Tested-by: Ulrich Weber <uw@ocedo.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv6/netfilter/nf_nat_masquerade_ipv6.c
net/netfilter/nf_conntrack_core.c