Skip to contentSkip to conversation

net: Misc follow-up on RTNL-less fib_rules series.

PATCH Applied Kuniyuki Iwashima 3 participants 6 messages Jul 2 – Jul 7

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net: Misc follow-up on RTNL-less fib_rules series.

Patch 1 moves net->ipv4.fib_table_hash_lock under
CONFIG_IP_MULTIPLE_TABLES.

Patch 2 adds mutex_destroy() for fib_rules_ops.lock.

Kuniyuki Iwashima (2):
ipv4: fib: Define fib_table_hash_lock under CONFIG_IP_MULTIPLE_TABLES.
net: fib_rules: Destroy ops->lock in fib_rules_unregister().

 Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst | 1 +
 include/net/netns/ipv4.h                                      | 2 +-
 net/core/fib_rules.c                                          | 1 +
 net/ipv4/fib_frontend.c                                       | 3 +++
 4 files changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.55.0.rc0.799.gd6f94ed593-goog
#1 lore raw

PATCH 1/2 ipv4: fib: Define fib_table_hash_lock under CONFIG_IP_MULTIPLE_TABLES.

When CONFIG_IP_MULTIPLE_TABLES is disabled, fib_new_table() is fib_get_table(), and no new table is created.

Let's move net->ipv4.fib_table_hash_lock under
CONFIG_IP_MULTIPLE_TABLES.

While at it, netns_ipv4_sysctl.rst is updated.

---
 Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst | 1 +
 include/net/netns/ipv4.h                                      | 2 +-
 net/ipv4/fib_frontend.c                                       | 3 +++
 3 files changed, 5 insertions(+), 1 deletion(-)
Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst +1 -0
index 6dbd97d435e9..3dc03bff739e 100644
@@ -22,6 +22,7 @@ struct_mutex                    ra_mutex
 struct_fib_rules_ops*           rules_ops
 struct_fib_table                fib_main
 struct_fib_table                fib_default
+spinlock_t                      fib_table_hash_lock
 unsigned_int                    fib_rules_require_fldissect
 bool                            fib_has_custom_rules
 bool                            fib_has_custom_local_routes
include/net/netns/ipv4.h +1 -1
index 59506320558a..cb7f8bf15671 100644
@@ -118,6 +118,7 @@ struct netns_ipv4 {
 	struct fib_rules_ops	*rules_ops;
 	struct fib_table __rcu	*fib_main;
 	struct fib_table __rcu	*fib_default;
+	spinlock_t		fib_table_hash_lock;
 	unsigned int		fib_rules_require_fldissect;
 	bool			fib_has_custom_rules;
 #endif
@@ -127,7 +128,6 @@ struct netns_ipv4 {
 	atomic_t		fib_num_tclassid_users;
 #endif
 	struct hlist_head	*fib_table_hash;
-	spinlock_t		fib_table_hash_lock;
 	struct sock		*fibnl;
 	struct hlist_head	*fib_info_hash;
 	unsigned int		fib_info_hash_bits;
net/ipv4/fib_frontend.c +3 -0
index 54eb72695093..6f5d0d25b110 100644
@@ -1584,7 +1584,10 @@ static int __net_init ip_fib_net_init(struct net *net)
 	net->ipv4.sysctl_fib_multipath_hash_fields =
 		FIB_MULTIPATH_HASH_FIELD_DEFAULT_MASK;
 #endif
+
+#ifdef CONFIG_IP_MULTIPLE_TABLES
 	spin_lock_init(&net->ipv4.fib_table_hash_lock);
+#endif
 
 	/* Avoid false sharing : Use at least a full cache line */
 	size = max_t(size_t, size, L1_CACHE_BYTES);
Signature · 1 line
2.55.0.rc0.799.gd6f94ed593-goog
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH v1 net-next 1/2] ipv4: fib: Define fib_table_hash_lock under CONFIG_IP_MULTIPLE_TABLES.

Quoted 10 lines · Kuniyuki Iwashima

When CONFIG_IP_MULTIPLE_TABLES is disabled, fib_new_table() is fib_get_table(), and no new table is created.

Let's move net->ipv4.fib_table_hash_lock under
CONFIG_IP_MULTIPLE_TABLES.

While at it, netns_ipv4_sysctl.rst is updated.

#3 lore raw

PATCH 2/2 net: fib_rules: Destroy ops->lock in fib_rules_unregister().

In reply to Kuniyuki Iwashima

Commit 8e133ba99cd8 ("net: fib_rules: Add fib_rules_ops.lock.") added mutex in struct fib_rules_ops, which is initialised in fib_rules_register().

Let's add paired mutex_destroy() in fib_rules_unregister().

---
 net/core/fib_rules.c | 1 +
 1 file changed, 1 insertion(+)
net/core/fib_rules.c +1 -0
index 22e5e5e1a9c4..7df216c17c67 100644
@@ -203,6 +203,7 @@ void fib_rules_unregister(struct fib_rules_ops *ops)
 	spin_unlock(&net->rules_mod_lock);
 
 	fib_rules_cleanup_ops(ops);
+	mutex_destroy(&ops->lock);
 	kfree_rcu(ops, rcu);
 }
 
Signature · 1 line
2.55.0.rc0.799.gd6f94ed593-goog
maintainer Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH v1 net-next 2/2] net: fib_rules: Destroy ops->lock in fib_rules_unregister().

Quoted 7 lines · Kuniyuki Iwashima

Commit 8e133ba99cd8 ("net: fib_rules: Add fib_rules_ops.lock.") added mutex in struct fib_rules_ops, which is initialised in fib_rules_register().

Let's add paired mutex_destroy() in fib_rules_unregister().

#5 lore raw
In reply to Kuniyuki Iwashima
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 11 lines · On Thu, 2 Jul 2026 04:44:13 +0000 you wrote:

Patch 1 moves net->ipv4.fib_table_hash_lock under
CONFIG_IP_MULTIPLE_TABLES.

Patch 2 adds mutex_destroy() for fib_rules_ops.lock.

Kuniyuki Iwashima (2):
ipv4: fib: Define fib_table_hash_lock under CONFIG_IP_MULTIPLE_TABLES.
net: fib_rules: Destroy ops->lock in fib_rules_unregister().

[...]

Here is the summary with links:
- [v1,net-next,1/2] ipv4: fib: Define fib_table_hash_lock under CONFIG_IP_MULTIPLE_TABLES.

    https://git.kernel.org/netdev/net-next/c/6041421dd087
  - [v1,net-next,2/2] net: fib_rules: Destroy ops->lock in fib_rules_unregister().
    https://git.kernel.org/netdev/net-next/c/99c13f8020df

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html