Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 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>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
81eccc13 434efd3d

+7 -16
+7 -16
drivers/net/pfcp.c
··· 245 245 return 0; 246 246 } 247 247 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) 249 250 { 250 251 struct pfcp_net *pn = net_generic(net, pfcp_net_id); 251 252 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); 259 253 260 254 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); 265 256 } 266 257 267 258 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), 272 263 }; 273 264 274 265 static int __init pfcp_init(void)