Skip to content

Commit 04dc7f6

Browse files
ebiedermdavem330
authored andcommitted
net: Move network device exit batching
Move network device exit batching from a special case in net_namespace.c to using common mechanisms in dev.c Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 72ad937 commit 04dc7f6

2 files changed

Lines changed: 25 additions & 24 deletions

File tree

‎net/core/dev.c‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5766,8 +5766,33 @@ static void __net_exit default_device_exit(struct net *net)
57665766
rtnl_unlock();
57675767
}
57685768

5769+
static void __net_exit default_device_exit_batch(struct list_head *net_list)
5770+
{
5771+
/* At exit all network devices most be removed from a network
5772+
* namespace. Do this in the reverse order of registeration.
5773+
* Do this across as many network namespaces as possible to
5774+
* improve batching efficiency.
5775+
*/
5776+
struct net_device *dev;
5777+
struct net *net;
5778+
LIST_HEAD(dev_kill_list);
5779+
5780+
rtnl_lock();
5781+
list_for_each_entry(net, net_list, exit_list) {
5782+
for_each_netdev_reverse(net, dev) {
5783+
if (dev->rtnl_link_ops)
5784+
dev->rtnl_link_ops->dellink(dev, &dev_kill_list);
5785+
else
5786+
unregister_netdevice_queue(dev, &dev_kill_list);
5787+
}
5788+
}
5789+
unregister_netdevice_many(&dev_kill_list);
5790+
rtnl_unlock();
5791+
}
5792+
57695793
static struct pernet_operations __net_initdata default_device_ops = {
57705794
.exit = default_device_exit,
5795+
.exit_batch = default_device_exit_batch,
57715796
};
57725797

57735798
/*

‎net/core/net_namespace.c‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
#include <linux/idr.h>
99
#include <linux/rculist.h>
1010
#include <linux/nsproxy.h>
11-
#include <linux/netdevice.h>
1211
#include <net/net_namespace.h>
1312
#include <net/netns/generic.h>
14-
#include <net/rtnetlink.h>
1513

1614
/*
1715
* Our network namespace constructor/destructor lists
@@ -29,20 +27,6 @@ EXPORT_SYMBOL(init_net);
2927

3028
#define INITIAL_NET_GEN_PTRS 13 /* +1 for len +2 for rcu_head */
3129

32-
static void unregister_netdevices(struct net *net, struct list_head *list)
33-
{
34-
struct net_device *dev;
35-
/* At exit all network devices most be removed from a network
36-
* namespace. Do this in the reverse order of registeration.
37-
*/
38-
for_each_netdev_reverse(net, dev) {
39-
if (dev->rtnl_link_ops)
40-
dev->rtnl_link_ops->dellink(dev, list);
41-
else
42-
unregister_netdevice_queue(dev, list);
43-
}
44-
}
45-
4630
static int ops_init(const struct pernet_operations *ops, struct net *net)
4731
{
4832
int err;
@@ -78,14 +62,6 @@ static void ops_exit_list(const struct pernet_operations *ops,
7862
list_for_each_entry(net, net_exit_list, exit_list)
7963
ops->exit(net);
8064
}
81-
if (&ops->list == first_device) {
82-
LIST_HEAD(dev_kill_list);
83-
rtnl_lock();
84-
list_for_each_entry(net, net_exit_list, exit_list)
85-
unregister_netdevices(net, &dev_kill_list);
86-
unregister_netdevice_many(&dev_kill_list);
87-
rtnl_unlock();
88-
}
8965
if (ops->exit_batch)
9066
ops->exit_batch(net_exit_list);
9167
}

0 commit comments

Comments
 (0)