geneve: move debug check after netdev unregister

[ Upstream commit 0fda7600c2e174fe27e9cf02e78e345226e441fa ]

The debug check must be done after unregister_netdevice_many() call --
the list_del() for this is done inside .ndo_stop.

Fixes: 2843a25348 ("geneve: speedup geneve tunnels dismantle")
Reported-and-tested-by: <syzbot+68a8ed58e3d17c700de5@syzkaller.appspotmail.com>
Cc: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Florian Westphal 2020-03-14 08:18:42 +01:00 committed by Greg Kroah-Hartman
parent 013b146529
commit 2c1a05e91f

View file

@ -1725,8 +1725,6 @@ static void geneve_destroy_tunnels(struct net *net, struct list_head *head)
if (!net_eq(dev_net(geneve->dev), net)) if (!net_eq(dev_net(geneve->dev), net))
unregister_netdevice_queue(geneve->dev, head); unregister_netdevice_queue(geneve->dev, head);
} }
WARN_ON_ONCE(!list_empty(&gn->sock_list));
} }
static void __net_exit geneve_exit_batch_net(struct list_head *net_list) static void __net_exit geneve_exit_batch_net(struct list_head *net_list)
@ -1741,6 +1739,12 @@ static void __net_exit geneve_exit_batch_net(struct list_head *net_list)
/* unregister the devices gathered above */ /* unregister the devices gathered above */
unregister_netdevice_many(&list); unregister_netdevice_many(&list);
rtnl_unlock(); rtnl_unlock();
list_for_each_entry(net, net_list, exit_list) {
const struct geneve_net *gn = net_generic(net, geneve_net_id);
WARN_ON_ONCE(!list_empty(&gn->sock_list));
}
} }
static struct pernet_operations geneve_net_ops = { static struct pernet_operations geneve_net_ops = {