From: Kuniyuki Iwashima Date: Fri, 12 Jun 2026 06:32:08 +0000 (+0000) Subject: ipv4: fib: Convert fib_net_exit_batch() to ->exit_rtnl(). X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=759923cf03b062b5b8cdc770e2819a67ebe1cacd;p=thirdparty%2Flinux.git 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 Reviewed-by: Ido Schimmel Reviewed-by: Eric Dumazet Link: https://patch.msgid.link/20260612063225.455191-6-kuniyu@google.com Signed-off-by: Jakub Kicinski --- diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index d147471d1d8e4..c7d1f31650d7b 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 = {