Skip to content

Commit a7ec251

Browse files
Eric Dumazetkuba-moo
authored andcommitted
nexthop: convert nexthop_net_exit_batch to exit_batch_rtnl method
exit_batch_rtnl() is called while RTNL is held. This saves one rtnl_lock()/rtnl_unlock() pair. We also need to create nexthop_net_exit() to make sure net->nexthop.devhash is not freed too soon, otherwise we will not be able to unregister netdev from exit_batch_rtnl() methods. Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: David Ahern <[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 fd4f101 commit a7ec251

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

net/ipv4/nexthop.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3737,16 +3737,20 @@ void nexthop_res_grp_activity_update(struct net *net, u32 id, u16 num_buckets,
37373737
}
37383738
EXPORT_SYMBOL(nexthop_res_grp_activity_update);
37393739

3740-
static void __net_exit nexthop_net_exit_batch(struct list_head *net_list)
3740+
static void __net_exit nexthop_net_exit_batch_rtnl(struct list_head *net_list,
3741+
struct list_head *dev_to_kill)
37413742
{
37423743
struct net *net;
37433744

3744-
rtnl_lock();
3745-
list_for_each_entry(net, net_list, exit_list) {
3745+
ASSERT_RTNL();
3746+
list_for_each_entry(net, net_list, exit_list)
37463747
flush_all_nexthops(net);
3747-
kfree(net->nexthop.devhash);
3748-
}
3749-
rtnl_unlock();
3748+
}
3749+
3750+
static void __net_exit nexthop_net_exit(struct net *net)
3751+
{
3752+
kfree(net->nexthop.devhash);
3753+
net->nexthop.devhash = NULL;
37503754
}
37513755

37523756
static int __net_init nexthop_net_init(struct net *net)
@@ -3764,7 +3768,8 @@ static int __net_init nexthop_net_init(struct net *net)
37643768

37653769
static struct pernet_operations nexthop_net_ops = {
37663770
.init = nexthop_net_init,
3767-
.exit_batch = nexthop_net_exit_batch,
3771+
.exit = nexthop_net_exit,
3772+
.exit_batch_rtnl = nexthop_net_exit_batch_rtnl,
37683773
};
37693774

37703775
static int __init nexthop_init(void)

0 commit comments

Comments
 (0)