@@ -4826,55 +4826,43 @@ static __net_init int vxlan_init_net(struct net *net)
48264826 NULL );
48274827}
48284828
4829- static void vxlan_destroy_tunnels (struct net * net , struct list_head * head )
4829+ static void __net_exit vxlan_destroy_tunnels (struct vxlan_net * vn ,
4830+ struct list_head * dev_to_kill )
48304831{
4831- struct vxlan_net * vn = net_generic (net , vxlan_net_id );
48324832 struct vxlan_dev * vxlan , * next ;
4833- struct net_device * dev , * aux ;
4834-
4835- for_each_netdev_safe (net , dev , aux )
4836- if (dev -> rtnl_link_ops == & vxlan_link_ops )
4837- unregister_netdevice_queue (dev , head );
4838-
4839- list_for_each_entry_safe (vxlan , next , & vn -> vxlan_list , next ) {
4840- /* If vxlan->dev is in the same netns, it has already been added
4841- * to the list by the previous loop.
4842- */
4843- if (!net_eq (dev_net (vxlan -> dev ), net ))
4844- unregister_netdevice_queue (vxlan -> dev , head );
4845- }
48464833
4834+ list_for_each_entry_safe (vxlan , next , & vn -> vxlan_list , next )
4835+ vxlan_dellink (vxlan -> dev , dev_to_kill );
48474836}
48484837
4849- static void __net_exit vxlan_exit_batch_net (struct list_head * net_list )
4838+ static void __net_exit vxlan_exit_batch_rtnl (struct list_head * net_list ,
4839+ struct list_head * dev_to_kill )
48504840{
48514841 struct net * net ;
4852- LIST_HEAD (list );
4853- unsigned int h ;
48544842
4843+ ASSERT_RTNL ();
48554844 list_for_each_entry (net , net_list , exit_list ) {
48564845 struct vxlan_net * vn = net_generic (net , vxlan_net_id );
48574846
4858- unregister_nexthop_notifier (net , & vn -> nexthop_notifier_block );
4859- }
4860- rtnl_lock ();
4861- list_for_each_entry (net , net_list , exit_list )
4862- vxlan_destroy_tunnels (net , & list );
4847+ __unregister_nexthop_notifier (net , & vn -> nexthop_notifier_block );
48634848
4864- unregister_netdevice_many (& list );
4865- rtnl_unlock ();
4849+ vxlan_destroy_tunnels (vn , dev_to_kill );
4850+ }
4851+ }
48664852
4867- list_for_each_entry (net , net_list , exit_list ) {
4868- struct vxlan_net * vn = net_generic (net , vxlan_net_id );
4853+ static void __net_exit vxlan_exit_net (struct net * net )
4854+ {
4855+ struct vxlan_net * vn = net_generic (net , vxlan_net_id );
4856+ unsigned int h ;
48694857
4870- for (h = 0 ; h < PORT_HASH_SIZE ; ++ h )
4871- WARN_ON_ONCE (!hlist_empty (& vn -> sock_list [h ]));
4872- }
4858+ for (h = 0 ; h < PORT_HASH_SIZE ; ++ h )
4859+ WARN_ON_ONCE (!hlist_empty (& vn -> sock_list [h ]));
48734860}
48744861
48754862static struct pernet_operations vxlan_net_ops = {
48764863 .init = vxlan_init_net ,
4877- .exit_batch = vxlan_exit_batch_net ,
4864+ .exit_batch_rtnl = vxlan_exit_batch_rtnl ,
4865+ .exit = vxlan_exit_net ,
48784866 .id = & vxlan_net_id ,
48794867 .size = sizeof (struct vxlan_net ),
48804868};
0 commit comments