diff options
| author | Kuniyuki Iwashima <kuniyu@google.com> | 2026-06-12 09:32:08 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-06-15 21:49:28 +0300 |
| commit | 759923cf03b062b5b8cdc770e2819a67ebe1cacd (patch) | |
| tree | d70e3ba5c6fc2f63858d14d28018c468a52966e6 | |
| parent | 5a7fef12d931f27e09767f8b7a9bf0c1ee096abd (diff) | |
| download | linux-759923cf03b062b5b8cdc770e2819a67ebe1cacd.tar.xz | |
ipv4: fib: Convert fib_net_exit_batch() to ->exit_rtnl().
Currently, IPv4 routes are flushed in ->exit_batch() after
all devices are unregistered.
Unlike IPv6, IPv4 routes are not added from the fast path,
so we can flush routes before default_device_exit_batch().
Let's call ip_fib_net_exit() from ->exit_rtnl() to save
one RTNL locking dance.
ip_fib_net_exit() must use list_del_rcu() for fib_table
for the fast path on dying dev.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260612063225.455191-6-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rw-r--r-- | net/ipv4/fib_frontend.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index d147471d1d8e..c7d1f31650d7 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -1607,7 +1607,7 @@ static void ip_fib_net_exit(struct net *net) struct fib_table *tb; hlist_for_each_entry_safe(tb, tmp, head, tb_hlist) { - hlist_del(&tb->tb_hlist); + hlist_del_rcu(&tb->tb_hlist); fib_table_flush(net, tb, true); fib_free_table(tb); } @@ -1663,29 +1663,24 @@ static void __net_exit fib_net_pre_exit(struct net *net) nl_fib_lookup_exit(net); } -static void __net_exit fib_net_exit_batch(struct list_head *net_list) +static void __net_exit fib_net_exit_rtnl(struct net *net, + struct list_head *dev_kill_list) { - struct net *net; - - rtnl_lock(); - list_for_each_entry(net, net_list, exit_list) { - __rtnl_net_lock(net); - ip_fib_net_exit(net); - __rtnl_net_unlock(net); - } - rtnl_unlock(); + ip_fib_net_exit(net); +} - list_for_each_entry(net, net_list, exit_list) { - kfree(net->ipv4.fib_table_hash); - fib4_notifier_exit(net); - fib4_semantics_exit(net); - } +static void __net_exit fib_net_exit(struct net *net) +{ + kfree(net->ipv4.fib_table_hash); + fib4_notifier_exit(net); + fib4_semantics_exit(net); } static struct pernet_operations fib_net_ops = { .init = fib_net_init, .pre_exit = fib_net_pre_exit, - .exit_batch = fib_net_exit_batch, + .exit_rtnl = fib_net_exit_rtnl, + .exit = fib_net_exit, }; static const struct rtnl_msg_handler fib_rtnl_msg_handlers[] __initconst = { |
