Skip to content

Commit 52e6701

Browse files
edumazetsmb49
authored andcommitted
gtp: use exit_batch_rtnl() method
BugLink: https://bugs.launchpad.net/bugs/2107449 [ Upstream commit 6eedda0 ] 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: 46841c7 ("gtp: Use for_each_netdev_rcu() in gtp_genl_dump_pdp().") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent dc72b7d commit 52e6701

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
@@ -1884,23 +1884,23 @@ static int __net_init gtp_net_init(struct net *net)
18841884
return 0;
18851885
}
18861886

1887-
static void __net_exit gtp_net_exit(struct net *net)
1887+
static void __net_exit gtp_net_exit_batch_rtnl(struct list_head *net_list,
1888+
struct list_head *dev_to_kill)
18881889
{
1889-
struct gtp_net *gn = net_generic(net, gtp_net_id);
1890-
struct gtp_dev *gtp;
1891-
LIST_HEAD(list);
1890+
struct net *net;
18921891

1893-
rtnl_lock();
1894-
list_for_each_entry(gtp, &gn->gtp_dev_list, list)
1895-
gtp_dellink(gtp->dev, &list);
1892+
list_for_each_entry(net, net_list, exit_list) {
1893+
struct gtp_net *gn = net_generic(net, gtp_net_id);
1894+
struct gtp_dev *gtp;
18961895

1897-
unregister_netdevice_many(&list);
1898-
rtnl_unlock();
1896+
list_for_each_entry(gtp, &gn->gtp_dev_list, list)
1897+
gtp_dellink(gtp->dev, dev_to_kill);
1898+
}
18991899
}
19001900

19011901
static struct pernet_operations gtp_net_ops = {
19021902
.init = gtp_net_init,
1903-
.exit = gtp_net_exit,
1903+
.exit_batch_rtnl = gtp_net_exit_batch_rtnl,
19041904
.id = &gtp_net_id,
19051905
.size = sizeof(struct gtp_net),
19061906
};

0 commit comments

Comments
 (0)