Skip to content

Commit

Permalink
xfrm: avoid synchronize_rcu during netns destruction
Browse files Browse the repository at this point in the history
Use the new exit_pre hook to NULL the netlink socket.
The net namespace core will do a synchronize_rcu() between the exit_pre
and exit/exit_batch handlers.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
  • Loading branch information
Florian Westphal authored and Steffen Klassert committed Apr 19, 2021
1 parent 7baf867 commit 6218fe1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions net/xfrm/xfrm_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -3480,18 +3480,22 @@ static int __net_init xfrm_user_net_init(struct net *net)
return 0;
}

static void __net_exit xfrm_user_net_pre_exit(struct net *net)
{
RCU_INIT_POINTER(net->xfrm.nlsk, NULL);
}

static void __net_exit xfrm_user_net_exit(struct list_head *net_exit_list)
{
struct net *net;
list_for_each_entry(net, net_exit_list, exit_list)
RCU_INIT_POINTER(net->xfrm.nlsk, NULL);
synchronize_net();

list_for_each_entry(net, net_exit_list, exit_list)
netlink_kernel_release(net->xfrm.nlsk_stash);
}

static struct pernet_operations xfrm_user_net_ops = {
.init = xfrm_user_net_init,
.pre_exit = xfrm_user_net_pre_exit,
.exit_batch = xfrm_user_net_exit,
};

Expand Down

0 comments on commit 6218fe1

Please sign in to comment.