Skip to content

Commit 4087c24

Browse files
Eric Dumazetmehmetb0
authored andcommitted
gtp: use exit_batch_rtnl() method
BugLink: https://bugs.launchpad.net/bugs/2097298 [ Upstream commit 6eedda01b2bfdcf427b37759e053dc27232f3af1 ] 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 <edumazet@google.com> Reviewed-by: Antoine Tenart <atenart@kernel.org> Link: https://lore.kernel.org/r/20240206144313.2050392-8-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Stable-dep-of: 46841c7053e6 ("gtp: Use for_each_netdev_rcu() in gtp_genl_dump_pdp().") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Noah Wager <noah.wager@canonical.com> Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
1 parent a052122 commit 4087c24

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
@@ -1403,23 +1403,23 @@ static int __net_init gtp_net_init(struct net *net)
14031403
return 0;
14041404
}
14051405

1406-
static void __net_exit gtp_net_exit(struct net *net)
1406+
static void __net_exit gtp_net_exit_batch_rtnl(struct list_head *net_list,
1407+
struct list_head *dev_to_kill)
14071408
{
1408-
struct gtp_net *gn = net_generic(net, gtp_net_id);
1409-
struct gtp_dev *gtp;
1410-
LIST_HEAD(list);
1409+
struct net *net;
14111410

1412-
rtnl_lock();
1413-
list_for_each_entry(gtp, &gn->gtp_dev_list, list)
1414-
gtp_dellink(gtp->dev, &list);
1411+
list_for_each_entry(net, net_list, exit_list) {
1412+
struct gtp_net *gn = net_generic(net, gtp_net_id);
1413+
struct gtp_dev *gtp;
14151414

1416-
unregister_netdevice_many(&list);
1417-
rtnl_unlock();
1415+
list_for_each_entry(gtp, &gn->gtp_dev_list, list)
1416+
gtp_dellink(gtp->dev, dev_to_kill);
1417+
}
14181418
}
14191419

14201420
static struct pernet_operations gtp_net_ops = {
14211421
.init = gtp_net_init,
1422-
.exit = gtp_net_exit,
1422+
.exit_batch_rtnl = gtp_net_exit_batch_rtnl,
14231423
.id = &gtp_net_id,
14241424
.size = sizeof(struct gtp_net),
14251425
};

0 commit comments

Comments
 (0)