Skip to content

Commit 659c019

Browse files
Eric Dumazetaloktiwa
authored andcommitted
gtp: use exit_batch_rtnl() method
[ 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 <[email protected]> Reviewed-by: Antoine Tenart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Stable-dep-of: 46841c7 ("gtp: Use for_each_netdev_rcu() in gtp_genl_dump_pdp().") Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 85d9663360988a434a46af25516c718308c471ba) Signed-off-by: Alok Tiwari <[email protected]>
1 parent d01397b commit 659c019

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
@@ -1355,23 +1355,23 @@ static int __net_init gtp_net_init(struct net *net)
13551355
return 0;
13561356
}
13571357

1358-
static void __net_exit gtp_net_exit(struct net *net)
1358+
static void __net_exit gtp_net_exit_batch_rtnl(struct list_head *net_list,
1359+
struct list_head *dev_to_kill)
13591360
{
1360-
struct gtp_net *gn = net_generic(net, gtp_net_id);
1361-
struct gtp_dev *gtp;
1362-
LIST_HEAD(list);
1361+
struct net *net;
13631362

1364-
rtnl_lock();
1365-
list_for_each_entry(gtp, &gn->gtp_dev_list, list)
1366-
gtp_dellink(gtp->dev, &list);
1363+
list_for_each_entry(net, net_list, exit_list) {
1364+
struct gtp_net *gn = net_generic(net, gtp_net_id);
1365+
struct gtp_dev *gtp;
13671366

1368-
unregister_netdevice_many(&list);
1369-
rtnl_unlock();
1367+
list_for_each_entry(gtp, &gn->gtp_dev_list, list)
1368+
gtp_dellink(gtp->dev, dev_to_kill);
1369+
}
13701370
}
13711371

13721372
static struct pernet_operations gtp_net_ops = {
13731373
.init = gtp_net_init,
1374-
.exit = gtp_net_exit,
1374+
.exit_batch_rtnl = gtp_net_exit_batch_rtnl,
13751375
.id = &gtp_net_id,
13761376
.size = sizeof(struct gtp_net),
13771377
};

0 commit comments

Comments
 (0)