Commit 81eccc13 authored by Kuniyuki Iwashima's avatar Kuniyuki Iwashima Committed by Jakub Kicinski
Browse files

pfcp: Convert pfcp_net_exit() to ->exit_rtnl().



pfcp_net_exit() holds RTNL and cleans up all devices in the netns
and other devices tied to sockets in the netns.

We can use ->exit_rtnl() to save RTNL dance for all dying netns.

Note that we delegate the for_each_netdev() part to
default_device_exit_batch() to avoid a list corruption splat
like the one reported in commit 4ccacf86 ("gtp: Suppress
list corruption splat in gtp_net_exit_batch_rtnl().")

Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250418003259.48017-3-kuniyu@amazon.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 434efd3d
Loading
Loading
Loading
Loading
+7 −16
Original line number Diff line number Diff line
@@ -245,28 +245,19 @@ static int __net_init pfcp_net_init(struct net *net)
	return 0;
}

static void __net_exit pfcp_net_exit(struct net *net)
static void __net_exit pfcp_net_exit_rtnl(struct net *net,
					  struct list_head *dev_to_kill)
{
	struct pfcp_net *pn = net_generic(net, pfcp_net_id);
	struct pfcp_dev *pfcp, *pfcp_next;
	struct net_device *dev;
	LIST_HEAD(list);

	rtnl_lock();
	for_each_netdev(net, dev)
		if (dev->rtnl_link_ops == &pfcp_link_ops)
			pfcp_dellink(dev, &list);

	list_for_each_entry_safe(pfcp, pfcp_next, &pn->pfcp_dev_list, list)
		pfcp_dellink(pfcp->dev, &list);

	unregister_netdevice_many(&list);
	rtnl_unlock();
		pfcp_dellink(pfcp->dev, dev_to_kill);
}

static struct pernet_operations pfcp_net_ops = {
	.init = pfcp_net_init,
	.exit	= pfcp_net_exit,
	.exit_rtnl = pfcp_net_exit_rtnl,
	.id = &pfcp_net_id,
	.size = sizeof(struct pfcp_net),
};