From: Kuniyuki Iwashima <kuniyu@amazon•com>
To: Andrew Lunn <andrew+netdev@lunn•ch>,
"David S. Miller" <davem@davemloft•net>,
Eric Dumazet <edumazet@google•com>,
Jakub Kicinski <kuba@kernel•org>, Paolo Abeni <pabeni@redhat•com>
Cc: Simon Horman <horms@kernel•org>,
Kuniyuki Iwashima <kuniyu@amazon•com>,
Kuniyuki Iwashima <kuni1840@gmail•com>, <netdev@vger•kernel.org>
Subject: [PATCH v2 net-next 2/3] pfcp: Convert pfcp_net_exit() to ->exit_rtnl().
Date: Thu, 17 Apr 2025 17:32:33 -0700 [thread overview]
Message-ID: <20250418003259.48017-3-kuniyu@amazon.com> (raw)
In-Reply-To: <20250418003259.48017-1-kuniyu@amazon.com>
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>
---
drivers/net/pfcp.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/drivers/net/pfcp.c b/drivers/net/pfcp.c
index f873a92d2445..28e6bc4a1f14 100644
--- a/drivers/net/pfcp.c
+++ b/drivers/net/pfcp.c
@@ -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)
--
2.49.0
next prev parent reply other threads:[~2025-04-18 0:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-18 0:32 [PATCH v2 net-next 0/3] net: Followup series for ->exit_rtnl() Kuniyuki Iwashima
2025-04-18 0:32 ` [PATCH v2 net-next 1/3] net: Drop hold_rtnl arg from ops_undo_list() Kuniyuki Iwashima
2025-04-18 0:32 ` Kuniyuki Iwashima [this message]
2025-04-23 2:47 ` [PATCH v2 net-next 2/3] pfcp: Convert pfcp_net_exit() to ->exit_rtnl() Jakub Kicinski
2025-04-23 8:37 ` Michal Swiatkowski
2025-04-23 13:33 ` Jakub Kicinski
2025-04-24 4:40 ` Michal Swiatkowski
2025-04-24 22:26 ` Jakub Kicinski
2025-04-25 4:28 ` Michal Swiatkowski
2025-04-23 13:40 ` Jakub Kicinski
2025-04-23 14:12 ` Kuniyuki Iwashima
2025-04-23 22:33 ` Jakub Kicinski
2025-04-23 22:52 ` Jakub Kicinski
2025-04-24 2:23 ` Kuniyuki Iwashima
2025-04-24 22:24 ` Jakub Kicinski
2025-04-18 0:32 ` [PATCH v2 net-next 3/3] ppp: Split ppp_exit_net() " Kuniyuki Iwashima
2025-04-23 2:50 ` [PATCH v2 net-next 0/3] net: Followup series for ->exit_rtnl() patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250418003259.48017-3-kuniyu@amazon.com \
--to=kuniyu@amazon$(echo .)com \
--cc=andrew+netdev@lunn$(echo .)ch \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=horms@kernel$(echo .)org \
--cc=kuba@kernel$(echo .)org \
--cc=kuni1840@gmail$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox