Skip to content

Commit 81eccc1

Browse files
q2venkuba-moo
authored andcommitted
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 4ccacf8 ("gtp: Suppress list corruption splat in gtp_net_exit_batch_rtnl().") Signed-off-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 434efd3 commit 81eccc1

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

drivers/net/pfcp.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -245,30 +245,21 @@ static int __net_init pfcp_net_init(struct net *net)
245245
return 0;
246246
}
247247

248-
static void __net_exit pfcp_net_exit(struct net *net)
248+
static void __net_exit pfcp_net_exit_rtnl(struct net *net,
249+
struct list_head *dev_to_kill)
249250
{
250251
struct pfcp_net *pn = net_generic(net, pfcp_net_id);
251252
struct pfcp_dev *pfcp, *pfcp_next;
252-
struct net_device *dev;
253-
LIST_HEAD(list);
254-
255-
rtnl_lock();
256-
for_each_netdev(net, dev)
257-
if (dev->rtnl_link_ops == &pfcp_link_ops)
258-
pfcp_dellink(dev, &list);
259253

260254
list_for_each_entry_safe(pfcp, pfcp_next, &pn->pfcp_dev_list, list)
261-
pfcp_dellink(pfcp->dev, &list);
262-
263-
unregister_netdevice_many(&list);
264-
rtnl_unlock();
255+
pfcp_dellink(pfcp->dev, dev_to_kill);
265256
}
266257

267258
static struct pernet_operations pfcp_net_ops = {
268-
.init = pfcp_net_init,
269-
.exit = pfcp_net_exit,
270-
.id = &pfcp_net_id,
271-
.size = sizeof(struct pfcp_net),
259+
.init = pfcp_net_init,
260+
.exit_rtnl = pfcp_net_exit_rtnl,
261+
.id = &pfcp_net_id,
262+
.size = sizeof(struct pfcp_net),
272263
};
273264

274265
static int __init pfcp_init(void)

0 commit comments

Comments
 (0)