net: Simplfy default_device_exit and improve batching.
- Defer dellink to net_cleanup() allowing for batching. - Fix comment. - Use for_each_netdev_safe again as dev_change_net_namespace touches at most one network device (unlike veth dellink). Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
999b6d39ab
commit
e008b5fc8d
@ -5736,14 +5736,13 @@ static struct pernet_operations __net_initdata netdev_net_ops = {
|
|||||||
|
|
||||||
static void __net_exit default_device_exit(struct net *net)
|
static void __net_exit default_device_exit(struct net *net)
|
||||||
{
|
{
|
||||||
struct net_device *dev;
|
struct net_device *dev, *aux;
|
||||||
/*
|
/*
|
||||||
* Push all migratable of the network devices back to the
|
* Push all migratable network devices back to the
|
||||||
* initial network namespace
|
* initial network namespace
|
||||||
*/
|
*/
|
||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
restart:
|
for_each_netdev_safe(net, dev, aux) {
|
||||||
for_each_netdev(net, dev) {
|
|
||||||
int err;
|
int err;
|
||||||
char fb_name[IFNAMSIZ];
|
char fb_name[IFNAMSIZ];
|
||||||
|
|
||||||
@ -5751,11 +5750,9 @@ restart:
|
|||||||
if (dev->features & NETIF_F_NETNS_LOCAL)
|
if (dev->features & NETIF_F_NETNS_LOCAL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Delete virtual devices */
|
/* Leave virtual devices for the generic cleanup */
|
||||||
if (dev->rtnl_link_ops && dev->rtnl_link_ops->dellink) {
|
if (dev->rtnl_link_ops)
|
||||||
dev->rtnl_link_ops->dellink(dev, NULL);
|
continue;
|
||||||
goto restart;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Push remaing network devices to init_net */
|
/* Push remaing network devices to init_net */
|
||||||
snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
|
snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
|
||||||
@ -5765,7 +5762,6 @@ restart:
|
|||||||
__func__, dev->name, err);
|
__func__, dev->name, err);
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
goto restart;
|
|
||||||
}
|
}
|
||||||
rtnl_unlock();
|
rtnl_unlock();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user