]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pfcp: Convert pfcp_net_exit() to ->exit_rtnl().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Fri, 18 Apr 2025 00:32:33 +0000 (17:32 -0700)
committerJakub Kicinski <kuba@kernel.org>
Wed, 23 Apr 2025 02:07:41 +0000 (19:07 -0700)
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 4ccacf86491d ("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>
drivers/net/pfcp.c

index f873a92d24459802003ef7da0778f0b124f85940..28e6bc4a1f14c801259e7e9adf6c682ac1aaa628 100644 (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)