@@ -1638,38 +1638,46 @@ static __net_init int geneve_init_net(struct net *net)
16381638 return 0 ;
16391639}
16401640
1641- static void __net_exit geneve_exit_net (struct net * net )
1641+ static void geneve_destroy_tunnels (struct net * net , struct list_head * head )
16421642{
16431643 struct geneve_net * gn = net_generic (net , geneve_net_id );
16441644 struct geneve_dev * geneve , * next ;
16451645 struct net_device * dev , * aux ;
1646- LIST_HEAD (list );
1647-
1648- rtnl_lock ();
16491646
16501647 /* gather any geneve devices that were moved into this ns */
16511648 for_each_netdev_safe (net , dev , aux )
16521649 if (dev -> rtnl_link_ops == & geneve_link_ops )
1653- unregister_netdevice_queue (dev , & list );
1650+ unregister_netdevice_queue (dev , head );
16541651
16551652 /* now gather any other geneve devices that were created in this ns */
16561653 list_for_each_entry_safe (geneve , next , & gn -> geneve_list , next ) {
16571654 /* If geneve->dev is in the same netns, it was already added
16581655 * to the list by the previous loop.
16591656 */
16601657 if (!net_eq (dev_net (geneve -> dev ), net ))
1661- unregister_netdevice_queue (geneve -> dev , & list );
1658+ unregister_netdevice_queue (geneve -> dev , head );
16621659 }
16631660
1661+ WARN_ON_ONCE (!list_empty (& gn -> sock_list ));
1662+ }
1663+
1664+ static void __net_exit geneve_exit_batch_net (struct list_head * net_list )
1665+ {
1666+ struct net * net ;
1667+ LIST_HEAD (list );
1668+
1669+ rtnl_lock ();
1670+ list_for_each_entry (net , net_list , exit_list )
1671+ geneve_destroy_tunnels (net , & list );
1672+
16641673 /* unregister the devices gathered above */
16651674 unregister_netdevice_many (& list );
16661675 rtnl_unlock ();
1667- WARN_ON_ONCE (!list_empty (& gn -> sock_list ));
16681676}
16691677
16701678static struct pernet_operations geneve_net_ops = {
16711679 .init = geneve_init_net ,
1672- .exit = geneve_exit_net ,
1680+ .exit_batch = geneve_exit_batch_net ,
16731681 .id = & geneve_net_id ,
16741682 .size = sizeof (struct geneve_net ),
16751683};
0 commit comments