From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A566372B4B for ; Mon, 29 Jun 2026 18:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782756753; cv=none; b=Z2/T9lEh5nRUs48t3ikGdNKqdCVNZ2zyFVM531YGyTV12wQ2rxkfvctcPszzgxMucfMn/stUSj9Vp4ZIgolOMJO1MWmTw70AfBa4zQYH0wDFnlXQq62N72x5bOMzPlT6gMJ1mGgHkRUAVH1wA8TIuxbJUyePKG09MybWGQMqIjQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782756753; c=relaxed/simple; bh=w40yZ5MJYHS2pr2MwShzm05JTL4ss/IMwryti29kRcY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VkTLceXC+svQi0XlvkynFHERcjIBtNabO6+/CSwDwWcOGC/G8wInPOuoQz7VBdYAl3T7cu+eCLk0R8hp7jwMecJgu5iKYEidbHqIrZOFhrah4Ftt7GQLMMzDjW+3ZPD8sG7WqcSSFulUsdnV0jbaFNyBg8BRHVeGuykDaTBr9Io= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZXziLQtC; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZXziLQtC" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2c9ed5caa3bso9397245ad.1 for ; Mon, 29 Jun 2026 11:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782756751; x=1783361551; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Hy/hCXit96TLAlp1EnAmOeuByVTqYVPjHSYBe1p0OWo=; b=ZXziLQtCGnpv+7UVBuosg8vF62xMwJf9XrqMLA+Y4uK5V7qGep8xyXnBLN2lFIpzWv wBXyaKyFVoK+nx25jzw3AGlxEtS+OtMaEFSrPw1Qvi41rxouQcQGcLYJXk7at848DZKP yQZi8WLP8WjAzKM3AJkEdP5DyGRGjUMJMi7mw62juud4v2YjQJ+zfGExEcz0m1F24UEg pp/brX3VeMy1aBM7tuFiMqkLXDtpNnzHy4orc/tQdTbpIVjyx3dj8iRS1YpbBxje7Ee9 ThN/8AyJ+59GVsorA2dyFHTfZKQGNjoRG9urIDxanDNjN4BYoQfEEK3H87pP0rYosbYc AN2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782756751; x=1783361551; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hy/hCXit96TLAlp1EnAmOeuByVTqYVPjHSYBe1p0OWo=; b=CRURJ/llcALwW2FUKAqhLMjYl82cCy+vEEEkYmrQz/YsQv1doCK+Cn/Got+FjuoWxQ BacG9fIE/v3iUg6edJ8PgjXQhA7Jm5qpRbrQPTMCL8B3izmNmm/HPC0nIKvUASPq/nO7 yKWKb93+mR/lxA+F/7PvCv2J0iKt/L1kzcqfmGLAL1W4aA+DMBenSYjbS9LFZbIkWhSs nT8gWzqWgWT2CGh+C2MZTM6YfIR7PgOEzUF9z90snY77ZvRcy8dAQa9ruGsTK7ZpGnMZ kXdmgnpFW9eszHY0jLkwKND7luBEDmjz894sHnDzr7Mk8HyAtFaHqcbiX+gvbSA+OByT BXfQ== X-Forwarded-Encrypted: i=1; AHgh+RqJQMIy2mRrXiWASGpN9xTswvrZWaRG0Nxg3ohv9eHpnOFHSNqUnLWIlVsALZPH4vZqKdFYN+8=@vger.kernel.org X-Gm-Message-State: AOJu0YwfARws8/cLjNX4F33W5sPn1cKUUeTcQIuiHYr2A5SFmRiJ8oFE Y4RG4KQ20kclAyYWfcmaMoq3vIRJUOWE0NiV2x0J9n8IrYHp+o0+IvxBz/bmJ+MDm8VutWFAVFl xKwvpWQ== X-Received: from plw20.prod.google.com ([2002:a17:903:45d4:b0:2c7:ef74:dfc]) (user=kuniyu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ea07:b0:2c8:5de:a84e with SMTP id d9443c01a7336-2ca2ea335cemr2514365ad.10.1782756751285; Mon, 29 Jun 2026 11:12:31 -0700 (PDT) Date: Mon, 29 Jun 2026 18:10:54 +0000 In-Reply-To: <20260629181226.1929658-1-kuniyu@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260629181226.1929658-1-kuniyu@google.com> X-Mailer: git-send-email 2.55.0.rc0.799.gd6f94ed593-goog Message-ID: <20260629181226.1929658-3-kuniyu@google.com> Subject: [PATCH v1 net-next 02/10] ipv4: fib_rules: Make the need for fib_unmerge() explicit. From: Kuniyuki Iwashima To: David Ahern , Ido Schimmel , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Kuniyuki Iwashima , Kuniyuki Iwashima , netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 --- net/ipv4/fib_rules.c | 10 ++++++---- 1 file 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) { -- 2.55.0.rc0.799.gd6f94ed593-goog