]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ipv4: fib: Convert fib_net_exit_batch() to ->exit_rtnl().
authorKuniyuki Iwashima <kuniyu@google.com>
Fri, 12 Jun 2026 06:32:08 +0000 (06:32 +0000)
committerJakub Kicinski <kuba@kernel.org>
Mon, 15 Jun 2026 18:49:28 +0000 (11:49 -0700)
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>
net/ipv4/fib_frontend.c

index d147471d1d8e486e7e9d8661ec8e46ac15ae15f1..c7d1f31650d7be66f286f38a1f6feae8e1664e0d 100644 (file)
@@ -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 = {