Skip to content

Commit 6eedda0

Browse files
Eric Dumazetkuba-moo
authored andcommitted
gtp: use exit_batch_rtnl() method
exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair per netns and one unregister_netdevice_many() call per netns. Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Antoine Tenart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f4b57b9 commit 6eedda0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/net/gtp.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,23 +1876,23 @@ static int __net_init gtp_net_init(struct net *net)
18761876
return 0;
18771877
}
18781878

1879-
static void __net_exit gtp_net_exit(struct net *net)
1879+
static void __net_exit gtp_net_exit_batch_rtnl(struct list_head *net_list,
1880+
struct list_head *dev_to_kill)
18801881
{
1881-
struct gtp_net *gn = net_generic(net, gtp_net_id);
1882-
struct gtp_dev *gtp;
1883-
LIST_HEAD(list);
1882+
struct net *net;
18841883

1885-
rtnl_lock();
1886-
list_for_each_entry(gtp, &gn->gtp_dev_list, list)
1887-
gtp_dellink(gtp->dev, &list);
1884+
list_for_each_entry(net, net_list, exit_list) {
1885+
struct gtp_net *gn = net_generic(net, gtp_net_id);
1886+
struct gtp_dev *gtp;
18881887

1889-
unregister_netdevice_many(&list);
1890-
rtnl_unlock();
1888+
list_for_each_entry(gtp, &gn->gtp_dev_list, list)
1889+
gtp_dellink(gtp->dev, dev_to_kill);
1890+
}
18911891
}
18921892

18931893
static struct pernet_operations gtp_net_ops = {
18941894
.init = gtp_net_init,
1895-
.exit = gtp_net_exit,
1895+
.exit_batch_rtnl = gtp_net_exit_batch_rtnl,
18961896
.id = &gtp_net_id,
18971897
.size = sizeof(struct gtp_net),
18981898
};

0 commit comments

Comments
 (0)