mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
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>
This commit is contained in:
parent
2a798e8c71
commit
2290727b2f
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user