Commit 6eedda01 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

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: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarAntoine Tenart <atenart@kernel.org>
Link: https://lore.kernel.org/r/20240206144313.2050392-8-edumazet@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f4b57b9d
...@@ -1876,23 +1876,23 @@ static int __net_init gtp_net_init(struct net *net) ...@@ -1876,23 +1876,23 @@ static int __net_init gtp_net_init(struct net *net)
return 0; return 0;
} }
static void __net_exit gtp_net_exit(struct net *net) static void __net_exit gtp_net_exit_batch_rtnl(struct list_head *net_list,
struct list_head *dev_to_kill)
{ {
struct gtp_net *gn = net_generic(net, gtp_net_id); struct net *net;
struct gtp_dev *gtp;
LIST_HEAD(list);
rtnl_lock(); list_for_each_entry(net, net_list, exit_list) {
list_for_each_entry(gtp, &gn->gtp_dev_list, list) struct gtp_net *gn = net_generic(net, gtp_net_id);
gtp_dellink(gtp->dev, &list); struct gtp_dev *gtp;
unregister_netdevice_many(&list); list_for_each_entry(gtp, &gn->gtp_dev_list, list)
rtnl_unlock(); gtp_dellink(gtp->dev, dev_to_kill);
}
} }
static struct pernet_operations gtp_net_ops = { static struct pernet_operations gtp_net_ops = {
.init = gtp_net_init, .init = gtp_net_init,
.exit = gtp_net_exit, .exit_batch_rtnl = gtp_net_exit_batch_rtnl,
.id = &gtp_net_id, .id = &gtp_net_id,
.size = sizeof(struct gtp_net), .size = sizeof(struct gtp_net),
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment