From: Kuniyuki Iwashima <kuniyu@google.com>
To: David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
Kuniyuki Iwashima <kuniyu@google.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
netdev@vger.kernel.org
Subject: [PATCH v1 net-next 5/5] ipv4: fib: Convert fib_net_exit_batch() to ->exit_rtnl().
Date: Fri, 12 Jun 2026 06:32:08 +0000 [thread overview]
Message-ID: <20260612063225.455191-6-kuniyu@google.com> (raw)
In-Reply-To: <20260612063225.455191-1-kuniyu@google.com>
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>
---
net/ipv4/fib_frontend.c | 29 ++++++++++++-----------------
1 file 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 = {
--
2.54.0.1136.gdb2ca164c4-goog
next prev parent reply other threads:[~2026-06-12 6:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 6:32 [PATCH v1 net-next 0/5] ipv4: fib: Remove RTNL in fib_net_exit_batch() Kuniyuki Iwashima
2026-06-12 6:32 ` [PATCH v1 net-next 1/5] ipv4: fib: Flush all fib_info in fib_table_flush() during netns dismantle Kuniyuki Iwashima
2026-06-15 12:38 ` Ido Schimmel
2026-06-12 6:32 ` [PATCH v1 net-next 2/5] ipv4: fib: Call fib_proc_exit() and nl_fib_lookup_exit() at ->pre_exit() Kuniyuki Iwashima
2026-06-15 12:38 ` Ido Schimmel
2026-06-12 6:32 ` [PATCH v1 net-next 3/5] ipv4: fib: Free net->ipv4.{fib_table_hash,notifier_ops} without RTNL Kuniyuki Iwashima
2026-06-15 12:38 ` Ido Schimmel
2026-06-12 6:32 ` [PATCH v1 net-next 4/5] ipv4: fib: Avoid calling fib_trie_table() in fib_new_table() for dying net Kuniyuki Iwashima
2026-06-15 12:39 ` Ido Schimmel
2026-06-12 6:32 ` Kuniyuki Iwashima [this message]
2026-06-15 12:39 ` [PATCH v1 net-next 5/5] ipv4: fib: Convert fib_net_exit_batch() to ->exit_rtnl() Ido Schimmel
2026-06-15 12:46 ` [PATCH v1 net-next 0/5] ipv4: fib: Remove RTNL in fib_net_exit_batch() Eric Dumazet
2026-06-15 19:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260612063225.455191-6-kuniyu@google.com \
--to=kuniyu@google.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.