Netdev List
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	edumazet@kernel.org, dsahern@kernel.org, horms@kernel.org,
	Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next 1/2] ipv4: Store netns in FIB table
Date: Wed, 14 Oct 2026 11:26:11 +0300	[thread overview]
Message-ID: <20261014082612.1280756-2-idosch@nvidia.com> (raw)
In-Reply-To: <20261014082612.1280756-1-idosch@nvidia.com>

The next patch will stop passing the network namespace to
fib_table_lookup() and instead pass the namespace from the FIB table to
the fib_table_lookup tracepoint. As a preparation, store the namespace
in the FIB table when the table is created.

The FIB table structure grows from 48 bytes to 56 bytes and still fits
in a single cache line.

No functional changes intended.

Assisted-by: LLM
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 include/net/ip_fib.h    | 4 +++-
 net/ipv4/fib_frontend.c | 6 +++---
 net/ipv4/fib_trie.c     | 6 ++++--
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index fb446f01a65d..033ed8fce35e 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -258,6 +258,7 @@ struct fib_table {
 	struct hlist_node	tb_hlist;
 	u32			tb_id;
 	int			tb_num_default;
+	struct net		*tb_net;
 	struct rcu_head		rcu;
 	unsigned long 		*tb_data;
 	unsigned long		__data[];
@@ -593,7 +594,8 @@ void fib_nh_common_release(struct fib_nh_common *nhc);
 /* Exported by fib_trie.c */
 void fib_alias_hw_flags_set(struct net *net, const struct fib_rt_info *fri);
 void fib_trie_init(void);
-struct fib_table *fib_trie_table(u32 id, struct fib_table *alias);
+struct fib_table *fib_trie_table(struct net *net, u32 id,
+				 struct fib_table *alias);
 bool fib_lookup_good_nhc(const struct fib_nh_common *nhc, int fib_flags,
 			 const struct flowi4 *flp);
 
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index c80c1b36f1fd..97acfb35fb12 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -54,11 +54,11 @@ static int __net_init fib4_rules_init(struct net *net)
 {
 	struct fib_table *local_table, *main_table;
 
-	main_table  = fib_trie_table(RT_TABLE_MAIN, NULL);
+	main_table = fib_trie_table(net, RT_TABLE_MAIN, NULL);
 	if (!main_table)
 		return -ENOMEM;
 
-	local_table = fib_trie_table(RT_TABLE_LOCAL, main_table);
+	local_table = fib_trie_table(net, RT_TABLE_LOCAL, main_table);
 	if (!local_table)
 		goto fail;
 
@@ -91,7 +91,7 @@ struct fib_table *fib_new_table(struct net *net, u32 id)
 	if (id == RT_TABLE_LOCAL && !net->ipv4.fib_has_custom_rules)
 		alias = fib_new_table(net, RT_TABLE_MAIN);
 
-	new_tb = fib_trie_table(id, alias);
+	new_tb = fib_trie_table(net, id, alias);
 	if (!new_tb)
 		return NULL;
 
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 4a800fdf1ad1..3bc8247b3d75 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1881,7 +1881,7 @@ struct fib_table *fib_trie_unmerge(struct fib_table *oldtb)
 	if (oldtb->tb_data == oldtb->__data)
 		return oldtb;
 
-	local_tb = fib_trie_table(RT_TABLE_LOCAL, NULL);
+	local_tb = fib_trie_table(oldtb->tb_net, RT_TABLE_LOCAL, NULL);
 	if (!local_tb)
 		return NULL;
 
@@ -2378,7 +2378,8 @@ void __init fib_trie_init(void)
 					   0, SLAB_PANIC | SLAB_ACCOUNT, NULL);
 }
 
-struct fib_table *fib_trie_table(u32 id, struct fib_table *alias)
+struct fib_table *fib_trie_table(struct net *net, u32 id,
+				 struct fib_table *alias)
 {
 	struct fib_table *tb;
 	struct trie *t;
@@ -2391,6 +2392,7 @@ struct fib_table *fib_trie_table(u32 id, struct fib_table *alias)
 	if (!tb)
 		return NULL;
 
+	tb->tb_net = net;
 	tb->tb_id = id;
 	tb->tb_num_default = 0;
 	tb->tb_data = (alias ? alias->__data : tb->__data);
-- 
2.56.0


  reply	other threads:[~2026-10-14  8:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14  8:26 [PATCH net-next 0/2] ipv4: Remove netns argument from fib_table_lookup() Ido Schimmel
2026-10-14  8:26 ` Ido Schimmel [this message]
2026-10-14 13:36   ` [PATCH net-next 1/2] ipv4: Store netns in FIB table David Ahern
2026-10-14  8:26 ` [PATCH net-next 2/2] ipv4: Do not pass netns to fib_table_lookup() Ido Schimmel
2026-10-14 13:36   ` David Ahern
2026-10-14  9:58 ` [PATCH net-next 0/2] ipv4: Remove netns argument from fib_table_lookup() Björn Töpel

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=20261014082612.1280756-2-idosch@nvidia.com \
    --to=idosch@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox