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.

ipmr: Move unregister_netdevice_many() out of mroute_clean_tables().

This is a prep commit to convert ipmr_net_exit_batch() to
->exit_rtnl().

Let's move unregister_netdevice_many() in mroute_clean_tables()
to its callers.

As a bonus, mrtsock_destruct() can do batching for all tables.

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260228221800.1082070-8-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
3810f952 2c698bab

+24 -10
+24 -10
net/ipv4/ipmr.c
··· 112 112 static void mroute_netlink_event(struct mr_table *mrt, struct mfc_cache *mfc, 113 113 int cmd); 114 114 static void igmpmsg_netlink_event(const struct mr_table *mrt, struct sk_buff *pkt); 115 - static void mroute_clean_tables(struct mr_table *mrt, int flags); 115 + static void mroute_clean_tables(struct mr_table *mrt, int flags, 116 + struct list_head *dev_kill_list); 116 117 static void ipmr_expire_process(struct timer_list *t); 117 118 118 119 #ifdef CONFIG_IP_MROUTE_MULTIPLE_TABLES ··· 428 427 static void ipmr_free_table(struct mr_table *mrt) 429 428 { 430 429 struct net *net = read_pnet(&mrt->net); 430 + LIST_HEAD(dev_kill_list); 431 431 432 432 WARN_ON_ONCE(!mr_can_free_table(net)); 433 433 434 434 timer_shutdown_sync(&mrt->ipmr_expire_timer); 435 435 mroute_clean_tables(mrt, MRT_FLUSH_VIFS | MRT_FLUSH_VIFS_STATIC | 436 - MRT_FLUSH_MFC | MRT_FLUSH_MFC_STATIC); 436 + MRT_FLUSH_MFC | MRT_FLUSH_MFC_STATIC, 437 + &dev_kill_list); 438 + unregister_netdevice_many(&dev_kill_list); 437 439 rhltable_destroy(&mrt->mfc_hash); 438 440 kfree(mrt); 439 441 } ··· 1297 1293 } 1298 1294 1299 1295 /* Close the multicast socket, and clear the vif tables etc */ 1300 - static void mroute_clean_tables(struct mr_table *mrt, int flags) 1296 + static void mroute_clean_tables(struct mr_table *mrt, int flags, 1297 + struct list_head *dev_kill_list) 1301 1298 { 1302 1299 struct net *net = read_pnet(&mrt->net); 1303 - struct mr_mfc *c, *tmp; 1304 1300 struct mfc_cache *cache; 1305 - LIST_HEAD(list); 1301 + struct mr_mfc *c, *tmp; 1306 1302 int i; 1307 1303 1308 1304 /* Shut down all active vif entries */ ··· 1312 1308 !(flags & MRT_FLUSH_VIFS_STATIC)) || 1313 1309 (!(mrt->vif_table[i].flags & VIFF_STATIC) && !(flags & MRT_FLUSH_VIFS))) 1314 1310 continue; 1315 - vif_delete(mrt, i, 0, &list); 1311 + vif_delete(mrt, i, 0, dev_kill_list); 1316 1312 } 1317 - unregister_netdevice_many(&list); 1318 1313 } 1319 1314 1320 1315 /* Wipe the cache */ ··· 1352 1349 static void mrtsock_destruct(struct sock *sk) 1353 1350 { 1354 1351 struct net *net = sock_net(sk); 1352 + LIST_HEAD(dev_kill_list); 1355 1353 struct mr_table *mrt; 1356 1354 1357 1355 rtnl_lock(); 1356 + 1358 1357 ipmr_for_each_table(mrt, net) { 1359 1358 if (sk == rtnl_dereference(mrt->mroute_sk)) { 1360 1359 IPV4_DEVCONF_ALL(net, MC_FORWARDING)--; ··· 1365 1360 NETCONFA_IFINDEX_ALL, 1366 1361 net->ipv4.devconf_all); 1367 1362 RCU_INIT_POINTER(mrt->mroute_sk, NULL); 1368 - mroute_clean_tables(mrt, MRT_FLUSH_VIFS | MRT_FLUSH_MFC); 1363 + mroute_clean_tables(mrt, MRT_FLUSH_VIFS | MRT_FLUSH_MFC, 1364 + &dev_kill_list); 1369 1365 } 1370 1366 } 1367 + 1368 + unregister_netdevice_many(&dev_kill_list); 1369 + 1371 1370 rtnl_unlock(); 1372 1371 } 1373 1372 ··· 1494 1485 sk == rtnl_dereference(mrt->mroute_sk), 1495 1486 parent); 1496 1487 break; 1497 - case MRT_FLUSH: 1488 + case MRT_FLUSH: { 1489 + LIST_HEAD(dev_kill_list); 1490 + 1498 1491 if (optlen != sizeof(val)) { 1499 1492 ret = -EINVAL; 1500 1493 break; ··· 1505 1494 ret = -EFAULT; 1506 1495 break; 1507 1496 } 1508 - mroute_clean_tables(mrt, val); 1497 + 1498 + mroute_clean_tables(mrt, val, &dev_kill_list); 1499 + unregister_netdevice_many(&dev_kill_list); 1509 1500 break; 1501 + } 1510 1502 /* Control PIM assert. */ 1511 1503 case MRT_ASSERT: 1512 1504 if (optlen != sizeof(val)) {