summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@google.com>2026-06-29 18:10:54 +0000
committerPaolo Abeni <pabeni@redhat.com>2026-07-01 18:42:33 +0200
commit5cb890ff73573f2924877d9a6b4a298f021a9cc5 (patch)
treeaaaa7f04e10327cb788f44f8e9fa8636e82236b9
parent54fd3962c99df50056660747a9e783af27410126 (diff)
downloadlinux-stable-5cb890ff73573f2924877d9a6b4a298f021a9cc5.tar.gz
linux-stable-5cb890ff73573f2924877d9a6b4a298f021a9cc5.zip
ipv4: fib_rules: Make the need for fib_unmerge() explicit.
IPv4 local and main route tables are merged by default to avoid unnecessary rule lookups. When the first IPv4 rule is created, fib_unmerge() splits the two tables. However, fib4_rule_configure() currently always calls fib_unmerge(), and even fetching a table via fib_get_table() requires RTNL (or RCU). We will drop RTNL from fib_newrule() if not needed. Let's call fib_unmerge() only once for the first rule. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260629181226.1929658-3-kuniyu@google.com Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-rw-r--r--net/ipv4/fib_rules.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 51d0ab423ed4..16d202246a36 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -301,10 +301,12 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
fib4_nl2rule_dscp_mask(tb[FRA_DSCP_MASK], rule4, extack) < 0)
goto errout;
- /* split local/main if they are not already split */
- err = fib_unmerge(net);
- if (err)
- goto errout;
+ if (!net->ipv4.fib_has_custom_rules) {
+ /* split local/main if they are not already split */
+ err = fib_unmerge(net);
+ if (err)
+ goto errout;
+ }
if (rule->table == RT_TABLE_UNSPEC && !rule->l3mdev) {
if (rule->action == FR_ACT_TO_TBL) {