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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-convert-exit_batch_rtnl-to-exit_rtnl'

Kuniyuki Iwashima says:

====================
net: Convert ->exit_batch_rtnl() to ->exit_rtnl().

While converting nexthop to per-netns RTNL, there are two blockers
to using rtnl_net_dereference(), flush_all_nexthops() and
__unregister_nexthop_notifier(), both of which are called from
->exit_batch_rtnl().

Instead of spreading __rtnl_net_lock() over each ->exit_batch_rtnl(),
we should convert all ->exit_batch_rtnl() to per-net ->exit_rtnl() and
run it under __rtnl_net_lock() because all ->exit_batch_rtnl() functions
do not have anything to factor out for batching.

Patch 1 & 2 factorise the undo mechanism against ->init() into a single
function, and Patch 3 adds ->exit_batch_rtnl().

Patch 4 ~ 13 convert all ->exit_batch_rtnl() users.

Patch 14 removes ->exit_batch_rtnl().

Later, we can convert pfcp and ppp to use ->exit_rtnl().

v1: https://lore.kernel.org/all/20250410022004.8668-1-kuniyu@amazon.com/
====================

Link: https://patch.msgid.link/20250411205258.63164-1-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+213 -300
+4 -12
drivers/net/bareudp.c
··· 777 777 return 0; 778 778 } 779 779 780 - static void bareudp_destroy_tunnels(struct net *net, struct list_head *head) 780 + static void __net_exit bareudp_exit_rtnl_net(struct net *net, 781 + struct list_head *dev_kill_list) 781 782 { 782 783 struct bareudp_net *bn = net_generic(net, bareudp_net_id); 783 784 struct bareudp_dev *bareudp, *next; 784 785 785 786 list_for_each_entry_safe(bareudp, next, &bn->bareudp_list, next) 786 - unregister_netdevice_queue(bareudp->dev, head); 787 - } 788 - 789 - static void __net_exit bareudp_exit_batch_rtnl(struct list_head *net_list, 790 - struct list_head *dev_kill_list) 791 - { 792 - struct net *net; 793 - 794 - list_for_each_entry(net, net_list, exit_list) 795 - bareudp_destroy_tunnels(net, dev_kill_list); 787 + bareudp_dellink(bareudp->dev, dev_kill_list); 796 788 } 797 789 798 790 static struct pernet_operations bareudp_net_ops = { 799 791 .init = bareudp_init_net, 800 - .exit_batch_rtnl = bareudp_exit_batch_rtnl, 792 + .exit_rtnl = bareudp_exit_rtnl_net, 801 793 .id = &bareudp_net_id, 802 794 .size = sizeof(struct bareudp_net), 803 795 };
+9 -14
drivers/net/bonding/bond_main.c
··· 6558 6558 6559 6559 /* According to commit 69b0216ac255 ("bonding: fix bonding_masters 6560 6560 * race condition in bond unloading") we need to remove sysfs files 6561 - * before we remove our devices (done later in bond_net_exit_batch_rtnl()) 6561 + * before we remove our devices (done later in bond_net_exit_rtnl()) 6562 6562 */ 6563 6563 static void __net_exit bond_net_pre_exit(struct net *net) 6564 6564 { ··· 6567 6567 bond_destroy_sysfs(bn); 6568 6568 } 6569 6569 6570 - static void __net_exit bond_net_exit_batch_rtnl(struct list_head *net_list, 6571 - struct list_head *dev_kill_list) 6570 + static void __net_exit bond_net_exit_rtnl(struct net *net, 6571 + struct list_head *dev_kill_list) 6572 6572 { 6573 - struct bond_net *bn; 6574 - struct net *net; 6573 + struct bond_net *bn = net_generic(net, bond_net_id); 6574 + struct bonding *bond, *tmp_bond; 6575 6575 6576 6576 /* Kill off any bonds created after unregistering bond rtnl ops */ 6577 - list_for_each_entry(net, net_list, exit_list) { 6578 - struct bonding *bond, *tmp_bond; 6579 - 6580 - bn = net_generic(net, bond_net_id); 6581 - list_for_each_entry_safe(bond, tmp_bond, &bn->dev_list, bond_list) 6582 - unregister_netdevice_queue(bond->dev, dev_kill_list); 6583 - } 6577 + list_for_each_entry_safe(bond, tmp_bond, &bn->dev_list, bond_list) 6578 + unregister_netdevice_queue(bond->dev, dev_kill_list); 6584 6579 } 6585 6580 6586 6581 /* According to commit 23fa5c2caae0 ("bonding: destroy proc directory 6587 6582 * only after all bonds are gone") bond_destroy_proc_dir() is called 6588 - * after bond_net_exit_batch_rtnl() has completed. 6583 + * after bond_net_exit_rtnl() has completed. 6589 6584 */ 6590 6585 static void __net_exit bond_net_exit_batch(struct list_head *net_list) 6591 6586 { ··· 6596 6601 static struct pernet_operations bond_net_ops = { 6597 6602 .init = bond_net_init, 6598 6603 .pre_exit = bond_net_pre_exit, 6599 - .exit_batch_rtnl = bond_net_exit_batch_rtnl, 6604 + .exit_rtnl = bond_net_exit_rtnl, 6600 6605 .exit_batch = bond_net_exit_batch, 6601 6606 .id = &bond_net_id, 6602 6607 .size = sizeof(struct bond_net),
+4 -12
drivers/net/geneve.c
··· 1946 1946 return 0; 1947 1947 } 1948 1948 1949 - static void geneve_destroy_tunnels(struct net *net, struct list_head *head) 1949 + static void __net_exit geneve_exit_rtnl_net(struct net *net, 1950 + struct list_head *dev_to_kill) 1950 1951 { 1951 1952 struct geneve_net *gn = net_generic(net, geneve_net_id); 1952 1953 struct geneve_dev *geneve, *next; 1953 1954 1954 1955 list_for_each_entry_safe(geneve, next, &gn->geneve_list, next) 1955 - geneve_dellink(geneve->dev, head); 1956 - } 1957 - 1958 - static void __net_exit geneve_exit_batch_rtnl(struct list_head *net_list, 1959 - struct list_head *dev_to_kill) 1960 - { 1961 - struct net *net; 1962 - 1963 - list_for_each_entry(net, net_list, exit_list) 1964 - geneve_destroy_tunnels(net, dev_to_kill); 1956 + geneve_dellink(geneve->dev, dev_to_kill); 1965 1957 } 1966 1958 1967 1959 static void __net_exit geneve_exit_net(struct net *net) ··· 1965 1973 1966 1974 static struct pernet_operations geneve_net_ops = { 1967 1975 .init = geneve_init_net, 1968 - .exit_batch_rtnl = geneve_exit_batch_rtnl, 1976 + .exit_rtnl = geneve_exit_rtnl_net, 1969 1977 .exit = geneve_exit_net, 1970 1978 .id = &geneve_net_id, 1971 1979 .size = sizeof(struct geneve_net),
+7 -11
drivers/net/gtp.c
··· 2475 2475 return 0; 2476 2476 } 2477 2477 2478 - static void __net_exit gtp_net_exit_batch_rtnl(struct list_head *net_list, 2479 - struct list_head *dev_to_kill) 2478 + static void __net_exit gtp_net_exit_rtnl(struct net *net, 2479 + struct list_head *dev_to_kill) 2480 2480 { 2481 - struct net *net; 2481 + struct gtp_net *gn = net_generic(net, gtp_net_id); 2482 + struct gtp_dev *gtp, *gtp_next; 2482 2483 2483 - list_for_each_entry(net, net_list, exit_list) { 2484 - struct gtp_net *gn = net_generic(net, gtp_net_id); 2485 - struct gtp_dev *gtp, *gtp_next; 2486 - 2487 - list_for_each_entry_safe(gtp, gtp_next, &gn->gtp_dev_list, list) 2488 - gtp_dellink(gtp->dev, dev_to_kill); 2489 - } 2484 + list_for_each_entry_safe(gtp, gtp_next, &gn->gtp_dev_list, list) 2485 + gtp_dellink(gtp->dev, dev_to_kill); 2490 2486 } 2491 2487 2492 2488 static struct pernet_operations gtp_net_ops = { 2493 2489 .init = gtp_net_init, 2494 - .exit_batch_rtnl = gtp_net_exit_batch_rtnl, 2490 + .exit_rtnl = gtp_net_exit_rtnl, 2495 2491 .id = &gtp_net_id, 2496 2492 .size = sizeof(struct gtp_net), 2497 2493 };
+7 -11
drivers/net/vxlan/vxlan_core.c
··· 4966 4966 vxlan_dellink(vxlan->dev, dev_to_kill); 4967 4967 } 4968 4968 4969 - static void __net_exit vxlan_exit_batch_rtnl(struct list_head *net_list, 4970 - struct list_head *dev_to_kill) 4969 + static void __net_exit vxlan_exit_rtnl(struct net *net, 4970 + struct list_head *dev_to_kill) 4971 4971 { 4972 - struct net *net; 4972 + struct vxlan_net *vn = net_generic(net, vxlan_net_id); 4973 4973 4974 - ASSERT_RTNL(); 4975 - list_for_each_entry(net, net_list, exit_list) { 4976 - struct vxlan_net *vn = net_generic(net, vxlan_net_id); 4974 + ASSERT_RTNL_NET(net); 4977 4975 4978 - __unregister_nexthop_notifier(net, &vn->nexthop_notifier_block); 4979 - 4980 - vxlan_destroy_tunnels(vn, dev_to_kill); 4981 - } 4976 + __unregister_nexthop_notifier(net, &vn->nexthop_notifier_block); 4977 + vxlan_destroy_tunnels(vn, dev_to_kill); 4982 4978 } 4983 4979 4984 4980 static void __net_exit vxlan_exit_net(struct net *net) ··· 4988 4992 4989 4993 static struct pernet_operations vxlan_net_ops = { 4990 4994 .init = vxlan_init_net, 4991 - .exit_batch_rtnl = vxlan_exit_batch_rtnl, 4995 + .exit_rtnl = vxlan_exit_rtnl, 4992 4996 .exit = vxlan_exit_net, 4993 4997 .id = &vxlan_net_id, 4994 4998 .size = sizeof(struct vxlan_net),
+3 -4
include/net/ip_tunnels.h
··· 377 377 int ip_tunnel_get_iflink(const struct net_device *dev); 378 378 int ip_tunnel_init_net(struct net *net, unsigned int ip_tnl_net_id, 379 379 struct rtnl_link_ops *ops, char *devname); 380 - 381 - void ip_tunnel_delete_nets(struct list_head *list_net, unsigned int id, 382 - struct rtnl_link_ops *ops, 383 - struct list_head *dev_to_kill); 380 + void ip_tunnel_delete_net(struct net *net, unsigned int id, 381 + struct rtnl_link_ops *ops, 382 + struct list_head *dev_to_kill); 384 383 385 384 void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, 386 385 const struct iphdr *tnl_params, const u8 protocol);
+2 -2
include/net/net_namespace.h
··· 475 475 void (*exit)(struct net *net); 476 476 void (*exit_batch)(struct list_head *net_exit_list); 477 477 /* Following method is called with RTNL held. */ 478 - void (*exit_batch_rtnl)(struct list_head *net_exit_list, 479 - struct list_head *dev_kill_list); 478 + void (*exit_rtnl)(struct net *net, 479 + struct list_head *dev_kill_list); 480 480 unsigned int * const id; 481 481 const size_t size; 482 482 };
+8 -9
net/bridge/br.c
··· 368 368 clear_bit(opt, &br->options); 369 369 } 370 370 371 - static void __net_exit br_net_exit_batch_rtnl(struct list_head *net_list, 372 - struct list_head *dev_to_kill) 371 + static void __net_exit br_net_exit_rtnl(struct net *net, 372 + struct list_head *dev_to_kill) 373 373 { 374 374 struct net_device *dev; 375 - struct net *net; 376 375 377 - ASSERT_RTNL(); 378 - list_for_each_entry(net, net_list, exit_list) 379 - for_each_netdev(net, dev) 380 - if (netif_is_bridge_master(dev)) 381 - br_dev_delete(dev, dev_to_kill); 376 + ASSERT_RTNL_NET(net); 377 + 378 + for_each_netdev(net, dev) 379 + if (netif_is_bridge_master(dev)) 380 + br_dev_delete(dev, dev_to_kill); 382 381 } 383 382 384 383 static struct pernet_operations br_net_ops = { 385 - .exit_batch_rtnl = br_net_exit_batch_rtnl, 384 + .exit_rtnl = br_net_exit_rtnl, 386 385 }; 387 386 388 387 static const struct stp_proto br_stp_proto = {
+95 -86
net/core/net_namespace.c
··· 163 163 } 164 164 } 165 165 166 + static void ops_exit_rtnl_list(const struct list_head *ops_list, 167 + const struct pernet_operations *ops, 168 + struct list_head *net_exit_list) 169 + { 170 + const struct pernet_operations *saved_ops = ops; 171 + LIST_HEAD(dev_kill_list); 172 + struct net *net; 173 + 174 + rtnl_lock(); 175 + 176 + list_for_each_entry(net, net_exit_list, exit_list) { 177 + __rtnl_net_lock(net); 178 + 179 + ops = saved_ops; 180 + list_for_each_entry_continue_reverse(ops, ops_list, list) { 181 + if (ops->exit_rtnl) 182 + ops->exit_rtnl(net, &dev_kill_list); 183 + } 184 + 185 + __rtnl_net_unlock(net); 186 + } 187 + 188 + unregister_netdevice_many(&dev_kill_list); 189 + 190 + rtnl_unlock(); 191 + } 192 + 166 193 static void ops_exit_list(const struct pernet_operations *ops, 167 194 struct list_head *net_exit_list) 168 195 { 169 - struct net *net; 170 196 if (ops->exit) { 197 + struct net *net; 198 + 171 199 list_for_each_entry(net, net_exit_list, exit_list) { 172 200 ops->exit(net); 173 201 cond_resched(); 174 202 } 175 203 } 204 + 176 205 if (ops->exit_batch) 177 206 ops->exit_batch(net_exit_list); 178 207 } ··· 215 186 list_for_each_entry(net, net_exit_list, exit_list) 216 187 kfree(net_generic(net, *ops->id)); 217 188 } 189 + } 190 + 191 + static void ops_undo_list(const struct list_head *ops_list, 192 + const struct pernet_operations *ops, 193 + struct list_head *net_exit_list, 194 + bool expedite_rcu, bool hold_rtnl) 195 + { 196 + const struct pernet_operations *saved_ops; 197 + 198 + if (!ops) 199 + ops = list_entry(ops_list, typeof(*ops), list); 200 + 201 + saved_ops = ops; 202 + 203 + list_for_each_entry_continue_reverse(ops, ops_list, list) 204 + ops_pre_exit_list(ops, net_exit_list); 205 + 206 + /* Another CPU might be rcu-iterating the list, wait for it. 207 + * This needs to be before calling the exit() notifiers, so the 208 + * rcu_barrier() after ops_undo_list() isn't sufficient alone. 209 + * Also the pre_exit() and exit() methods need this barrier. 210 + */ 211 + if (expedite_rcu) 212 + synchronize_rcu_expedited(); 213 + else 214 + synchronize_rcu(); 215 + 216 + if (hold_rtnl) 217 + ops_exit_rtnl_list(ops_list, saved_ops, net_exit_list); 218 + 219 + ops = saved_ops; 220 + list_for_each_entry_continue_reverse(ops, ops_list, list) 221 + ops_exit_list(ops, net_exit_list); 222 + 223 + ops = saved_ops; 224 + list_for_each_entry_continue_reverse(ops, ops_list, list) 225 + ops_free_list(ops, net_exit_list); 226 + } 227 + 228 + static void ops_undo_single(struct pernet_operations *ops, 229 + struct list_head *net_exit_list) 230 + { 231 + bool hold_rtnl = !!ops->exit_rtnl; 232 + LIST_HEAD(ops_list); 233 + 234 + list_add(&ops->list, &ops_list); 235 + ops_undo_list(&ops_list, NULL, net_exit_list, false, hold_rtnl); 236 + list_del(&ops->list); 218 237 } 219 238 220 239 /* should be called with nsid_lock held */ ··· 428 351 static __net_init int setup_net(struct net *net) 429 352 { 430 353 /* Must be called with pernet_ops_rwsem held */ 431 - const struct pernet_operations *ops, *saved_ops; 354 + const struct pernet_operations *ops; 432 355 LIST_HEAD(net_exit_list); 433 - LIST_HEAD(dev_kill_list); 434 356 int error = 0; 435 357 436 358 preempt_disable(); ··· 452 376 * for the pernet modules whose init functions did not fail. 453 377 */ 454 378 list_add(&net->exit_list, &net_exit_list); 455 - saved_ops = ops; 456 - list_for_each_entry_continue_reverse(ops, &pernet_list, list) 457 - ops_pre_exit_list(ops, &net_exit_list); 458 - 459 - synchronize_rcu(); 460 - 461 - ops = saved_ops; 462 - rtnl_lock(); 463 - list_for_each_entry_continue_reverse(ops, &pernet_list, list) { 464 - if (ops->exit_batch_rtnl) 465 - ops->exit_batch_rtnl(&net_exit_list, &dev_kill_list); 466 - } 467 - unregister_netdevice_many(&dev_kill_list); 468 - rtnl_unlock(); 469 - 470 - ops = saved_ops; 471 - list_for_each_entry_continue_reverse(ops, &pernet_list, list) 472 - ops_exit_list(ops, &net_exit_list); 473 - 474 - ops = saved_ops; 475 - list_for_each_entry_continue_reverse(ops, &pernet_list, list) 476 - ops_free_list(ops, &net_exit_list); 477 - 379 + ops_undo_list(&pernet_list, ops, &net_exit_list, false, true); 478 380 rcu_barrier(); 479 381 goto out; 480 382 } ··· 648 594 649 595 static void cleanup_net(struct work_struct *work) 650 596 { 651 - const struct pernet_operations *ops; 652 - struct net *net, *tmp, *last; 653 597 struct llist_node *net_kill_list; 598 + struct net *net, *tmp, *last; 654 599 LIST_HEAD(net_exit_list); 655 - LIST_HEAD(dev_kill_list); 656 600 657 601 cleanup_net_task = current; 658 602 ··· 681 629 list_add_tail(&net->exit_list, &net_exit_list); 682 630 } 683 631 684 - /* Run all of the network namespace pre_exit methods */ 685 - list_for_each_entry_reverse(ops, &pernet_list, list) 686 - ops_pre_exit_list(ops, &net_exit_list); 687 - 688 - /* 689 - * Another CPU might be rcu-iterating the list, wait for it. 690 - * This needs to be before calling the exit() notifiers, so 691 - * the rcu_barrier() below isn't sufficient alone. 692 - * Also the pre_exit() and exit() methods need this barrier. 693 - */ 694 - synchronize_rcu_expedited(); 695 - 696 - rtnl_lock(); 697 - list_for_each_entry_reverse(ops, &pernet_list, list) { 698 - if (ops->exit_batch_rtnl) 699 - ops->exit_batch_rtnl(&net_exit_list, &dev_kill_list); 700 - } 701 - unregister_netdevice_many(&dev_kill_list); 702 - rtnl_unlock(); 703 - 704 - /* Run all of the network namespace exit methods */ 705 - list_for_each_entry_reverse(ops, &pernet_list, list) 706 - ops_exit_list(ops, &net_exit_list); 707 - 708 - /* Free the net generic variables */ 709 - list_for_each_entry_reverse(ops, &pernet_list, list) 710 - ops_free_list(ops, &net_exit_list); 632 + ops_undo_list(&pernet_list, NULL, &net_exit_list, true, true); 711 633 712 634 up_read(&pernet_ops_rwsem); 713 635 ··· 1265 1239 rtnl_register_many(net_ns_rtnl_msg_handlers); 1266 1240 } 1267 1241 1268 - static void free_exit_list(struct pernet_operations *ops, struct list_head *net_exit_list) 1269 - { 1270 - ops_pre_exit_list(ops, net_exit_list); 1271 - synchronize_rcu(); 1272 - 1273 - if (ops->exit_batch_rtnl) { 1274 - LIST_HEAD(dev_kill_list); 1275 - 1276 - rtnl_lock(); 1277 - ops->exit_batch_rtnl(net_exit_list, &dev_kill_list); 1278 - unregister_netdevice_many(&dev_kill_list); 1279 - rtnl_unlock(); 1280 - } 1281 - ops_exit_list(ops, net_exit_list); 1282 - 1283 - ops_free_list(ops, net_exit_list); 1284 - } 1285 - 1286 1242 #ifdef CONFIG_NET_NS 1287 1243 static int __register_pernet_operations(struct list_head *list, 1288 1244 struct pernet_operations *ops) 1289 1245 { 1246 + LIST_HEAD(net_exit_list); 1290 1247 struct net *net; 1291 1248 int error; 1292 - LIST_HEAD(net_exit_list); 1293 1249 1294 1250 list_add_tail(&ops->list, list); 1295 1251 if (ops->init || ops->id) { ··· 1290 1282 out_undo: 1291 1283 /* If I have an error cleanup all namespaces I initialized */ 1292 1284 list_del(&ops->list); 1293 - free_exit_list(ops, &net_exit_list); 1285 + ops_undo_single(ops, &net_exit_list); 1294 1286 return error; 1295 1287 } 1296 1288 1297 1289 static void __unregister_pernet_operations(struct pernet_operations *ops) 1298 1290 { 1299 - struct net *net; 1300 1291 LIST_HEAD(net_exit_list); 1292 + struct net *net; 1301 1293 1302 - list_del(&ops->list); 1303 1294 /* See comment in __register_pernet_operations() */ 1304 1295 for_each_net(net) 1305 1296 list_add_tail(&net->exit_list, &net_exit_list); 1306 1297 1307 - free_exit_list(ops, &net_exit_list); 1298 + list_del(&ops->list); 1299 + ops_undo_single(ops, &net_exit_list); 1308 1300 } 1309 1301 1310 1302 #else ··· 1312 1304 static int __register_pernet_operations(struct list_head *list, 1313 1305 struct pernet_operations *ops) 1314 1306 { 1315 - if (!init_net_initialized) { 1316 - list_add_tail(&ops->list, list); 1307 + list_add_tail(&ops->list, list); 1308 + 1309 + if (!init_net_initialized) 1317 1310 return 0; 1318 - } 1319 1311 1320 1312 return ops_init(ops, &init_net); 1321 1313 } 1322 1314 1323 1315 static void __unregister_pernet_operations(struct pernet_operations *ops) 1324 1316 { 1325 - if (!init_net_initialized) { 1326 - list_del(&ops->list); 1327 - } else { 1317 + list_del(&ops->list); 1318 + 1319 + if (init_net_initialized) { 1328 1320 LIST_HEAD(net_exit_list); 1321 + 1329 1322 list_add(&init_net.exit_list, &net_exit_list); 1330 - free_exit_list(ops, &net_exit_list); 1323 + ops_undo_single(ops, &net_exit_list); 1331 1324 } 1332 1325 } 1333 1326
+12 -15
net/ipv4/ip_gre.c
··· 1066 1066 return ip_tunnel_init_net(net, ipgre_net_id, &ipgre_link_ops, NULL); 1067 1067 } 1068 1068 1069 - static void __net_exit ipgre_exit_batch_rtnl(struct list_head *list_net, 1070 - struct list_head *dev_to_kill) 1069 + static void __net_exit ipgre_exit_rtnl(struct net *net, 1070 + struct list_head *dev_to_kill) 1071 1071 { 1072 - ip_tunnel_delete_nets(list_net, ipgre_net_id, &ipgre_link_ops, 1073 - dev_to_kill); 1072 + ip_tunnel_delete_net(net, ipgre_net_id, &ipgre_link_ops, dev_to_kill); 1074 1073 } 1075 1074 1076 1075 static struct pernet_operations ipgre_net_ops = { 1077 1076 .init = ipgre_init_net, 1078 - .exit_batch_rtnl = ipgre_exit_batch_rtnl, 1077 + .exit_rtnl = ipgre_exit_rtnl, 1079 1078 .id = &ipgre_net_id, 1080 1079 .size = sizeof(struct ip_tunnel_net), 1081 1080 }; ··· 1751 1752 return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "gretap0"); 1752 1753 } 1753 1754 1754 - static void __net_exit ipgre_tap_exit_batch_rtnl(struct list_head *list_net, 1755 - struct list_head *dev_to_kill) 1755 + static void __net_exit ipgre_tap_exit_rtnl(struct net *net, 1756 + struct list_head *dev_to_kill) 1756 1757 { 1757 - ip_tunnel_delete_nets(list_net, gre_tap_net_id, &ipgre_tap_ops, 1758 - dev_to_kill); 1758 + ip_tunnel_delete_net(net, gre_tap_net_id, &ipgre_tap_ops, dev_to_kill); 1759 1759 } 1760 1760 1761 1761 static struct pernet_operations ipgre_tap_net_ops = { 1762 1762 .init = ipgre_tap_init_net, 1763 - .exit_batch_rtnl = ipgre_tap_exit_batch_rtnl, 1763 + .exit_rtnl = ipgre_tap_exit_rtnl, 1764 1764 .id = &gre_tap_net_id, 1765 1765 .size = sizeof(struct ip_tunnel_net), 1766 1766 }; ··· 1770 1772 &erspan_link_ops, "erspan0"); 1771 1773 } 1772 1774 1773 - static void __net_exit erspan_exit_batch_rtnl(struct list_head *net_list, 1774 - struct list_head *dev_to_kill) 1775 + static void __net_exit erspan_exit_rtnl(struct net *net, 1776 + struct list_head *dev_to_kill) 1775 1777 { 1776 - ip_tunnel_delete_nets(net_list, erspan_net_id, &erspan_link_ops, 1777 - dev_to_kill); 1778 + ip_tunnel_delete_net(net, erspan_net_id, &erspan_link_ops, dev_to_kill); 1778 1779 } 1779 1780 1780 1781 static struct pernet_operations erspan_net_ops = { 1781 1782 .init = erspan_init_net, 1782 - .exit_batch_rtnl = erspan_exit_batch_rtnl, 1783 + .exit_rtnl = erspan_exit_rtnl, 1783 1784 .id = &erspan_net_id, 1784 1785 .size = sizeof(struct ip_tunnel_net), 1785 1786 };
+7 -18
net/ipv4/ip_tunnel.c
··· 1174 1174 } 1175 1175 EXPORT_SYMBOL_GPL(ip_tunnel_init_net); 1176 1176 1177 - static void ip_tunnel_destroy(struct net *net, struct ip_tunnel_net *itn, 1178 - struct list_head *head, 1179 - struct rtnl_link_ops *ops) 1177 + void ip_tunnel_delete_net(struct net *net, unsigned int id, 1178 + struct rtnl_link_ops *ops, 1179 + struct list_head *head) 1180 1180 { 1181 + struct ip_tunnel_net *itn = net_generic(net, id); 1181 1182 struct net_device *dev, *aux; 1182 1183 int h; 1184 + 1185 + ASSERT_RTNL_NET(net); 1183 1186 1184 1187 for_each_netdev_safe(net, dev, aux) 1185 1188 if (dev->rtnl_link_ops == ops) ··· 1201 1198 unregister_netdevice_queue(t->dev, head); 1202 1199 } 1203 1200 } 1204 - 1205 - void ip_tunnel_delete_nets(struct list_head *net_list, unsigned int id, 1206 - struct rtnl_link_ops *ops, 1207 - struct list_head *dev_to_kill) 1208 - { 1209 - struct ip_tunnel_net *itn; 1210 - struct net *net; 1211 - 1212 - ASSERT_RTNL(); 1213 - list_for_each_entry(net, net_list, exit_list) { 1214 - itn = net_generic(net, id); 1215 - ip_tunnel_destroy(net, itn, dev_to_kill, ops); 1216 - } 1217 - } 1218 - EXPORT_SYMBOL_GPL(ip_tunnel_delete_nets); 1201 + EXPORT_SYMBOL_GPL(ip_tunnel_delete_net); 1219 1202 1220 1203 int ip_tunnel_newlink(struct net *net, struct net_device *dev, 1221 1204 struct nlattr *tb[], struct ip_tunnel_parm_kern *p,
+4 -5
net/ipv4/ip_vti.c
··· 523 523 return 0; 524 524 } 525 525 526 - static void __net_exit vti_exit_batch_rtnl(struct list_head *list_net, 527 - struct list_head *dev_to_kill) 526 + static void __net_exit vti_exit_rtnl(struct net *net, 527 + struct list_head *dev_to_kill) 528 528 { 529 - ip_tunnel_delete_nets(list_net, vti_net_id, &vti_link_ops, 530 - dev_to_kill); 529 + ip_tunnel_delete_net(net, vti_net_id, &vti_link_ops, dev_to_kill); 531 530 } 532 531 533 532 static struct pernet_operations vti_net_ops = { 534 533 .init = vti_init_net, 535 - .exit_batch_rtnl = vti_exit_batch_rtnl, 534 + .exit_rtnl = vti_exit_rtnl, 536 535 .id = &vti_net_id, 537 536 .size = sizeof(struct ip_tunnel_net), 538 537 };
+4 -5
net/ipv4/ipip.c
··· 604 604 return ip_tunnel_init_net(net, ipip_net_id, &ipip_link_ops, "tunl0"); 605 605 } 606 606 607 - static void __net_exit ipip_exit_batch_rtnl(struct list_head *list_net, 608 - struct list_head *dev_to_kill) 607 + static void __net_exit ipip_exit_rtnl(struct net *net, 608 + struct list_head *dev_to_kill) 609 609 { 610 - ip_tunnel_delete_nets(list_net, ipip_net_id, &ipip_link_ops, 611 - dev_to_kill); 610 + ip_tunnel_delete_net(net, ipip_net_id, &ipip_link_ops, dev_to_kill); 612 611 } 613 612 614 613 static struct pernet_operations ipip_net_ops = { 615 614 .init = ipip_init_net, 616 - .exit_batch_rtnl = ipip_exit_batch_rtnl, 615 + .exit_rtnl = ipip_exit_rtnl, 617 616 .id = &ipip_net_id, 618 617 .size = sizeof(struct ip_tunnel_net), 619 618 };
+5 -8
net/ipv4/nexthop.c
··· 4040 4040 } 4041 4041 EXPORT_SYMBOL(nexthop_res_grp_activity_update); 4042 4042 4043 - static void __net_exit nexthop_net_exit_batch_rtnl(struct list_head *net_list, 4044 - struct list_head *dev_to_kill) 4043 + static void __net_exit nexthop_net_exit_rtnl(struct net *net, 4044 + struct list_head *dev_to_kill) 4045 4045 { 4046 - struct net *net; 4047 - 4048 - ASSERT_RTNL(); 4049 - list_for_each_entry(net, net_list, exit_list) 4050 - flush_all_nexthops(net); 4046 + ASSERT_RTNL_NET(net); 4047 + flush_all_nexthops(net); 4051 4048 } 4052 4049 4053 4050 static void __net_exit nexthop_net_exit(struct net *net) ··· 4069 4072 static struct pernet_operations nexthop_net_ops = { 4070 4073 .init = nexthop_net_init, 4071 4074 .exit = nexthop_net_exit, 4072 - .exit_batch_rtnl = nexthop_net_exit_batch_rtnl, 4075 + .exit_rtnl = nexthop_net_exit_rtnl, 4073 4076 }; 4074 4077 4075 4078 static const struct rtnl_msg_handler nexthop_rtnl_msg_handlers[] __initconst = {
+6 -16
net/ipv6/ip6_gre.c
··· 1570 1570 .flags = INET6_PROTO_FINAL, 1571 1571 }; 1572 1572 1573 - static void ip6gre_destroy_tunnels(struct net *net, struct list_head *head) 1573 + static void __net_exit ip6gre_exit_rtnl_net(struct net *net, struct list_head *head) 1574 1574 { 1575 1575 struct ip6gre_net *ign = net_generic(net, ip6gre_net_id); 1576 1576 struct net_device *dev, *aux; ··· 1587 1587 for (h = 0; h < IP6_GRE_HASH_SIZE; h++) { 1588 1588 struct ip6_tnl *t; 1589 1589 1590 - t = rtnl_dereference(ign->tunnels[prio][h]); 1590 + t = rtnl_net_dereference(net, ign->tunnels[prio][h]); 1591 1591 1592 1592 while (t) { 1593 1593 /* If dev is in the same netns, it has already 1594 1594 * been added to the list by the previous loop. 1595 1595 */ 1596 1596 if (!net_eq(dev_net(t->dev), net)) 1597 - unregister_netdevice_queue(t->dev, 1598 - head); 1599 - t = rtnl_dereference(t->next); 1597 + unregister_netdevice_queue(t->dev, head); 1598 + 1599 + t = rtnl_net_dereference(net, t->next); 1600 1600 } 1601 1601 } 1602 1602 } ··· 1640 1640 return err; 1641 1641 } 1642 1642 1643 - static void __net_exit ip6gre_exit_batch_rtnl(struct list_head *net_list, 1644 - struct list_head *dev_to_kill) 1645 - { 1646 - struct net *net; 1647 - 1648 - ASSERT_RTNL(); 1649 - list_for_each_entry(net, net_list, exit_list) 1650 - ip6gre_destroy_tunnels(net, dev_to_kill); 1651 - } 1652 - 1653 1643 static struct pernet_operations ip6gre_net_ops = { 1654 1644 .init = ip6gre_init_net, 1655 - .exit_batch_rtnl = ip6gre_exit_batch_rtnl, 1645 + .exit_rtnl = ip6gre_exit_rtnl_net, 1656 1646 .id = &ip6gre_net_id, 1657 1647 .size = sizeof(struct ip6gre_net), 1658 1648 };
+8 -16
net/ipv6/ip6_tunnel.c
··· 2210 2210 .priority = 1, 2211 2211 }; 2212 2212 2213 - static void __net_exit ip6_tnl_destroy_tunnels(struct net *net, struct list_head *list) 2213 + static void __net_exit ip6_tnl_exit_rtnl_net(struct net *net, struct list_head *list) 2214 2214 { 2215 2215 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); 2216 2216 struct net_device *dev, *aux; ··· 2222 2222 unregister_netdevice_queue(dev, list); 2223 2223 2224 2224 for (h = 0; h < IP6_TUNNEL_HASH_SIZE; h++) { 2225 - t = rtnl_dereference(ip6n->tnls_r_l[h]); 2225 + t = rtnl_net_dereference(net, ip6n->tnls_r_l[h]); 2226 2226 while (t) { 2227 2227 /* If dev is in the same netns, it has already 2228 2228 * been added to the list by the previous loop. 2229 2229 */ 2230 2230 if (!net_eq(dev_net(t->dev), net)) 2231 2231 unregister_netdevice_queue(t->dev, list); 2232 - t = rtnl_dereference(t->next); 2232 + 2233 + t = rtnl_net_dereference(net, t->next); 2233 2234 } 2234 2235 } 2235 2236 2236 - t = rtnl_dereference(ip6n->tnls_wc[0]); 2237 + t = rtnl_net_dereference(net, ip6n->tnls_wc[0]); 2237 2238 while (t) { 2238 2239 /* If dev is in the same netns, it has already 2239 2240 * been added to the list by the previous loop. 2240 2241 */ 2241 2242 if (!net_eq(dev_net(t->dev), net)) 2242 2243 unregister_netdevice_queue(t->dev, list); 2243 - t = rtnl_dereference(t->next); 2244 + 2245 + t = rtnl_net_dereference(net, t->next); 2244 2246 } 2245 2247 } 2246 2248 ··· 2289 2287 return err; 2290 2288 } 2291 2289 2292 - static void __net_exit ip6_tnl_exit_batch_rtnl(struct list_head *net_list, 2293 - struct list_head *dev_to_kill) 2294 - { 2295 - struct net *net; 2296 - 2297 - ASSERT_RTNL(); 2298 - list_for_each_entry(net, net_list, exit_list) 2299 - ip6_tnl_destroy_tunnels(net, dev_to_kill); 2300 - } 2301 - 2302 2290 static struct pernet_operations ip6_tnl_net_ops = { 2303 2291 .init = ip6_tnl_init_net, 2304 - .exit_batch_rtnl = ip6_tnl_exit_batch_rtnl, 2292 + .exit_rtnl = ip6_tnl_exit_rtnl_net, 2305 2293 .id = &ip6_tnl_net_id, 2306 2294 .size = sizeof(struct ip6_tnl_net), 2307 2295 };
+7 -20
net/ipv6/ip6_vti.c
··· 1112 1112 .get_link_net = ip6_tnl_get_link_net, 1113 1113 }; 1114 1114 1115 - static void __net_exit vti6_destroy_tunnels(struct vti6_net *ip6n, 1116 - struct list_head *list) 1115 + static void __net_exit vti6_exit_rtnl_net(struct net *net, struct list_head *list) 1117 1116 { 1118 - int h; 1117 + struct vti6_net *ip6n = net_generic(net, vti6_net_id); 1119 1118 struct ip6_tnl *t; 1119 + int h; 1120 1120 1121 1121 for (h = 0; h < IP6_VTI_HASH_SIZE; h++) { 1122 - t = rtnl_dereference(ip6n->tnls_r_l[h]); 1122 + t = rtnl_net_dereference(net, ip6n->tnls_r_l[h]); 1123 1123 while (t) { 1124 1124 unregister_netdevice_queue(t->dev, list); 1125 - t = rtnl_dereference(t->next); 1125 + t = rtnl_net_dereference(net, t->next); 1126 1126 } 1127 1127 } 1128 1128 1129 - t = rtnl_dereference(ip6n->tnls_wc[0]); 1129 + t = rtnl_net_dereference(net, ip6n->tnls_wc[0]); 1130 1130 if (t) 1131 1131 unregister_netdevice_queue(t->dev, list); 1132 1132 } ··· 1170 1170 return err; 1171 1171 } 1172 1172 1173 - static void __net_exit vti6_exit_batch_rtnl(struct list_head *net_list, 1174 - struct list_head *dev_to_kill) 1175 - { 1176 - struct vti6_net *ip6n; 1177 - struct net *net; 1178 - 1179 - ASSERT_RTNL(); 1180 - list_for_each_entry(net, net_list, exit_list) { 1181 - ip6n = net_generic(net, vti6_net_id); 1182 - vti6_destroy_tunnels(ip6n, dev_to_kill); 1183 - } 1184 - } 1185 - 1186 1173 static struct pernet_operations vti6_net_ops = { 1187 1174 .init = vti6_init_net, 1188 - .exit_batch_rtnl = vti6_exit_batch_rtnl, 1175 + .exit_rtnl = vti6_exit_rtnl_net, 1189 1176 .id = &vti6_net_id, 1190 1177 .size = sizeof(struct vti6_net), 1191 1178 };
+6 -17
net/ipv6/sit.c
··· 1804 1804 }; 1805 1805 #endif 1806 1806 1807 - static void __net_exit sit_destroy_tunnels(struct net *net, 1808 - struct list_head *head) 1807 + static void __net_exit sit_exit_rtnl_net(struct net *net, struct list_head *head) 1809 1808 { 1810 1809 struct sit_net *sitn = net_generic(net, sit_net_id); 1811 1810 struct net_device *dev, *aux; ··· 1819 1820 for (h = 0; h < (prio ? IP6_SIT_HASH_SIZE : 1); h++) { 1820 1821 struct ip_tunnel *t; 1821 1822 1822 - t = rtnl_dereference(sitn->tunnels[prio][h]); 1823 + t = rtnl_net_dereference(net, sitn->tunnels[prio][h]); 1823 1824 while (t) { 1824 1825 /* If dev is in the same netns, it has already 1825 1826 * been added to the list by the previous loop. 1826 1827 */ 1827 1828 if (!net_eq(dev_net(t->dev), net)) 1828 - unregister_netdevice_queue(t->dev, 1829 - head); 1830 - t = rtnl_dereference(t->next); 1829 + unregister_netdevice_queue(t->dev, head); 1830 + 1831 + t = rtnl_net_dereference(net, t->next); 1831 1832 } 1832 1833 } 1833 1834 } ··· 1880 1881 return err; 1881 1882 } 1882 1883 1883 - static void __net_exit sit_exit_batch_rtnl(struct list_head *net_list, 1884 - struct list_head *dev_to_kill) 1885 - { 1886 - struct net *net; 1887 - 1888 - ASSERT_RTNL(); 1889 - list_for_each_entry(net, net_list, exit_list) 1890 - sit_destroy_tunnels(net, dev_to_kill); 1891 - } 1892 - 1893 1884 static struct pernet_operations sit_net_ops = { 1894 1885 .init = sit_init_net, 1895 - .exit_batch_rtnl = sit_exit_batch_rtnl, 1886 + .exit_rtnl = sit_exit_rtnl_net, 1896 1887 .id = &sit_net_id, 1897 1888 .size = sizeof(struct sit_net), 1898 1889 };
+15 -19
net/xfrm/xfrm_interface_core.c
··· 952 952 .get_link_net = xfrmi_get_link_net, 953 953 }; 954 954 955 - static void __net_exit xfrmi_exit_batch_rtnl(struct list_head *net_exit_list, 956 - struct list_head *dev_to_kill) 955 + static void __net_exit xfrmi_exit_rtnl(struct net *net, 956 + struct list_head *dev_to_kill) 957 957 { 958 - struct net *net; 958 + struct xfrmi_net *xfrmn = net_generic(net, xfrmi_net_id); 959 + struct xfrm_if __rcu **xip; 960 + struct xfrm_if *xi; 961 + int i; 959 962 960 - ASSERT_RTNL(); 961 - list_for_each_entry(net, net_exit_list, exit_list) { 962 - struct xfrmi_net *xfrmn = net_generic(net, xfrmi_net_id); 963 - struct xfrm_if __rcu **xip; 964 - struct xfrm_if *xi; 965 - int i; 966 - 967 - for (i = 0; i < XFRMI_HASH_SIZE; i++) { 968 - for (xip = &xfrmn->xfrmi[i]; 969 - (xi = rtnl_dereference(*xip)) != NULL; 970 - xip = &xi->next) 971 - unregister_netdevice_queue(xi->dev, dev_to_kill); 972 - } 973 - xi = rtnl_dereference(xfrmn->collect_md_xfrmi); 974 - if (xi) 963 + for (i = 0; i < XFRMI_HASH_SIZE; i++) { 964 + for (xip = &xfrmn->xfrmi[i]; 965 + (xi = rtnl_net_dereference(net, *xip)) != NULL; 966 + xip = &xi->next) 975 967 unregister_netdevice_queue(xi->dev, dev_to_kill); 976 968 } 969 + 970 + xi = rtnl_net_dereference(net, xfrmn->collect_md_xfrmi); 971 + if (xi) 972 + unregister_netdevice_queue(xi->dev, dev_to_kill); 977 973 } 978 974 979 975 static struct pernet_operations xfrmi_net_ops = { 980 - .exit_batch_rtnl = xfrmi_exit_batch_rtnl, 976 + .exit_rtnl = xfrmi_exit_rtnl, 981 977 .id = &xfrmi_net_id, 982 978 .size = sizeof(struct xfrmi_net), 983 979 };