STT unregisters nf-hook when there are no other STT devices left in the namespace. On some kernel versions the nf-unreg API take RTNL lock, but it is already taken in the tunnel device destroy code path which results in deadlock. To fix the issue I moved the unreg call into net-exit.
Bug: #1582410 Reported-by: Joe Stringer <j...@ovn.org> Signed-off-by: Pravin B Shelar <pshe...@nicira.com> --- datapath/linux/compat/stt.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/datapath/linux/compat/stt.c b/datapath/linux/compat/stt.c index 85ddbe7..5046c4c 100644 --- a/datapath/linux/compat/stt.c +++ b/datapath/linux/compat/stt.c @@ -1586,12 +1586,6 @@ static void stt_cleanup(struct net *net) sn->n_tunnels--; if (sn->n_tunnels) goto out; -#ifdef HAVE_NF_REGISTER_NET_HOOK - nf_unregister_net_hook(net, &nf_hook_ops); -#else - nf_unregister_hook(&nf_hook_ops); -#endif - out: n_tunnels--; if (n_tunnels) @@ -1668,6 +1662,7 @@ static int stt_stop(struct net_device *dev) struct net *net = stt_dev->net; list_del_rcu(&stt_dev->up_next); + synchronize_net(); tcp_sock_release(stt_dev->sock); stt_dev->sock = NULL; stt_cleanup(net); @@ -1869,6 +1864,14 @@ static void stt_exit_net(struct net *net) struct net_device *dev, *aux; LIST_HEAD(list); +#ifdef HAVE_NF_REGISTER_NET_HOOK + /* Ideally this should be done from stt_stop(), But on some kernels + * nf-unreg operation needs RTNL-lock, which can cause deallock. + * So it is done from here. */ + if (!list_empty(&nf_hook_ops.list)) + nf_unregister_net_hook(net, &nf_hook_ops); +#endif + rtnl_lock(); /* gather any stt devices that were moved into this ns */ @@ -1918,6 +1921,10 @@ out1: void stt_cleanup_module(void) { +#ifndef HAVE_NF_REGISTER_NET_HOOK + if (!list_empty(&nf_hook_ops.list)) + nf_unregister_hook(&nf_hook_ops); +#endif rtnl_link_unregister(&stt_link_ops); unregister_pernet_subsys(&stt_net_ops); } -- 1.8.3.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev