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 4ccacf8649 ("gtp: Suppress
list corruption splat in gtp_net_exit_batch_rtnl().")

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250418003259.48017-3-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Kuniyuki Iwashima 2025-04-17 17:32:33 -07:00 committed by Jakub Kicinski
parent 434efd3d0c
commit 81eccc131b

View file

@ -245,30 +245,21 @@ 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,
.id = &pfcp_net_id,
.size = sizeof(struct pfcp_net),
.init = pfcp_net_init,
.exit_rtnl = pfcp_net_exit_rtnl,
.id = &pfcp_net_id,
.size = sizeof(struct pfcp_net),
};
static int __init pfcp_init(void)