Skip to content

Commit

Permalink
net: Simplfy default_device_exit and improve batching.
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
ebiederm authored and davem330 committed Dec 2, 2009
1 parent 999b6d3 commit e008b5f
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -5736,26 +5736,23 @@ static struct pernet_operations __net_initdata netdev_net_ops = {

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
*/
rtnl_lock();
restart:
for_each_netdev(net, dev) {
for_each_netdev_safe(net, dev, aux) {
int err;
char fb_name[IFNAMSIZ];

/* Ignore unmoveable devices (i.e. loopback) */
if (dev->features & NETIF_F_NETNS_LOCAL)
continue;

/* Delete virtual devices */
if (dev->rtnl_link_ops && dev->rtnl_link_ops->dellink) {
dev->rtnl_link_ops->dellink(dev, NULL);
goto restart;
}
/* Leave virtual devices for the generic cleanup */
if (dev->rtnl_link_ops)
continue;

/* Push remaing network devices to init_net */
snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
Expand All @@ -5765,7 +5762,6 @@ static void __net_exit default_device_exit(struct net *net)
__func__, dev->name, err);
BUG();
}
goto restart;
}
rtnl_unlock();
}
Expand Down

0 comments on commit e008b5f

Please sign in to comment.