diff options
| author | Kuniyuki Iwashima <kuniyu@google.com> | 2026-06-04 22:46:31 +0000 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-06-08 17:06:24 -0700 |
| commit | 2290727b2fdb9f56f6fa2e06b4c5061c4f28e2df (patch) | |
| tree | 7fc3912945c5f34c0e9983fb8cabd828a92b2f0b | |
| parent | 2a798e8c71b569b3adca009ceb558ff2a936c4d9 (diff) | |
| download | linux-stable-2290727b2fdb9f56f6fa2e06b4c5061c4f28e2df.tar.gz linux-stable-2290727b2fdb9f56f6fa2e06b4c5061c4f28e2df.zip | |
ip6mr: Remove RTNL in ip6mr_rules_init() and ip6mr_net_init().
When ip6mr_free_table() is called from ip6mr_rules_init() or
ip6mr_net_init(), the netns is not yet published.
Thus, no device should have been registered, and
mroute_clean_tables() will not call mif6_delete(), so
unregister_netdevice_many() is unnecessary.
unregister_netdevice_many() does nothing if the list is empty,
but it requires RTNL due to the unconditional ASSERT_RTNL()
at the entry of unregister_netdevice_many_notify().
Let's remove unnecessary RTNL and ASSERT_RTNL() and instead
add WARN_ON_ONCE() in ip6mr_free_table().
Note that we use a local list for the new WARN_ON_ONCE() because
dev_kill_list passed from ip6mr_rules_exit_rtnl() may have some
devices when other ops->init() fails after ipmr durnig setup_net().
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260604224712.3209821-14-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rw-r--r-- | net/ipv6/ip6mr.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index e9560205b547..b13ce9c2c463 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -253,10 +253,7 @@ static int __net_init ip6mr_rules_init(struct net *net) return 0; err2: - rtnl_lock(); ip6mr_free_table(mrt, &dev_kill_list); - unregister_netdevice_many(&dev_kill_list); - rtnl_unlock(); err1: fib_rules_unregister(ops); return err; @@ -272,7 +269,6 @@ static void __net_exit ip6mr_rules_exit_rtnl(struct net *net, { struct mr_table *mrt, *next; - ASSERT_RTNL(); list_for_each_entry_safe(mrt, next, &net->ipv6.mr6_tables, list) { list_del_rcu(&mrt->list); ip6mr_free_table(mrt, dev_kill_list); @@ -345,8 +341,6 @@ static void __net_exit ip6mr_rules_exit_rtnl(struct net *net, { struct mr_table *mrt = rcu_dereference_protected(net->ipv6.mrt6, 1); - ASSERT_RTNL(); - RCU_INIT_POINTER(net->ipv6.mrt6, NULL); ip6mr_free_table(mrt, dev_kill_list); } @@ -427,15 +421,19 @@ static void ip6mr_free_table(struct mr_table *mrt, struct list_head *dev_kill_list) { struct net *net = read_pnet(&mrt->net); + LIST_HEAD(ip6mr_dev_kill_list); WARN_ON_ONCE(!mr_can_free_table(net)); timer_shutdown_sync(&mrt->ipmr_expire_timer); mroute_clean_tables(mrt, MRT6_FLUSH_MIFS | MRT6_FLUSH_MIFS_STATIC | MRT6_FLUSH_MFC | MRT6_FLUSH_MFC_STATIC, - dev_kill_list); + &ip6mr_dev_kill_list); mr_table_free(mrt); + + WARN_ON_ONCE(!net_initialized(net) && !list_empty(&ip6mr_dev_kill_list)); + list_splice(&ip6mr_dev_kill_list, dev_kill_list); } #ifdef CONFIG_PROC_FS @@ -1384,10 +1382,7 @@ static int __net_init ip6mr_net_init(struct net *net) proc_cache_fail: remove_proc_entry("ip6_mr_vif", net->proc_net); proc_vif_fail: - rtnl_lock(); ip6mr_rules_exit_rtnl(net, &dev_kill_list); - unregister_netdevice_many(&dev_kill_list); - rtnl_unlock(); ip6mr_rules_exit(net); #endif ip6mr_rules_fail: |
