Skip to content

Commit 8962dac

Browse files
edumazetkuba-moo
authored andcommitted
xfrm: interface: 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. 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 806b678 commit 8962dac

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

net/xfrm/xfrm_interface_core.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -957,12 +957,12 @@ static struct rtnl_link_ops xfrmi_link_ops __read_mostly = {
957957
.get_link_net = xfrmi_get_link_net,
958958
};
959959

960-
static void __net_exit xfrmi_exit_batch_net(struct list_head *net_exit_list)
960+
static void __net_exit xfrmi_exit_batch_rtnl(struct list_head *net_exit_list,
961+
struct list_head *dev_to_kill)
961962
{
962963
struct net *net;
963-
LIST_HEAD(list);
964964

965-
rtnl_lock();
965+
ASSERT_RTNL();
966966
list_for_each_entry(net, net_exit_list, exit_list) {
967967
struct xfrmi_net *xfrmn = net_generic(net, xfrmi_net_id);
968968
struct xfrm_if __rcu **xip;
@@ -973,18 +973,16 @@ static void __net_exit xfrmi_exit_batch_net(struct list_head *net_exit_list)
973973
for (xip = &xfrmn->xfrmi[i];
974974
(xi = rtnl_dereference(*xip)) != NULL;
975975
xip = &xi->next)
976-
unregister_netdevice_queue(xi->dev, &list);
976+
unregister_netdevice_queue(xi->dev, dev_to_kill);
977977
}
978978
xi = rtnl_dereference(xfrmn->collect_md_xfrmi);
979979
if (xi)
980-
unregister_netdevice_queue(xi->dev, &list);
980+
unregister_netdevice_queue(xi->dev, dev_to_kill);
981981
}
982-
unregister_netdevice_many(&list);
983-
rtnl_unlock();
984982
}
985983

986984
static struct pernet_operations xfrmi_net_ops = {
987-
.exit_batch = xfrmi_exit_batch_net,
985+
.exit_batch_rtnl = xfrmi_exit_batch_rtnl,
988986
.id = &xfrmi_net_id,
989987
.size = sizeof(struct xfrmi_net),
990988
};

0 commit comments

Comments
 (0)