🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20559

[RFC net-next 3/6] nexthop: factor out nh_has_f6i()

#20559
From: David Ahern
Date: Sun, 22 Nov 2026 22:27
58 lines
9314 bytes
From: David Ahern <dahern@nvidia.com>

nh_rt_cache_flush() open codes a locked check of whether any IPv6
routes use a nexthop. Move it into a helper, placed ahead of
remove_nexthop_from_groups(), so the next patch can use it there as
well.

No functional change.

Signed-off-by: David Ahern <dahern@nvidia.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
---
 net/ipv4/nexthop.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 42e55b5a755e..53431fe7d328 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -2109,6 +2109,17 @@ remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge,
 	return false;
 }
 
+static bool nh_has_f6i(struct nexthop *nh)
+{
+	bool have_f6i;
+
+	spin_lock_bh(&nh->lock);
+	have_f6i = !list_empty(&nh->f6i_list);
+	spin_unlock_bh(&nh->lock);
+
+	return have_f6i;
+}
+
 static bool __must_check
 remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
 			   struct nl_info *nlinfo)
@@ -2248,16 +2259,12 @@ static void nh_rt_cache_flush(struct net *net, struct nexthop *nh,
 			      struct nexthop *replaced_nh)
 {
 	struct nh_group *nhg;
-	bool have_f6i;
 	int i;
 
 	if (!list_empty(&nh->fi_list))
 		rt_cache_flush(net);
 
-	spin_lock_bh(&nh->lock);
-	have_f6i = !list_empty(&nh->f6i_list);
-	spin_unlock_bh(&nh->lock);
-	if (have_f6i)
+	if (nh_has_f6i(nh))
 		rt_genid_bump_ipv6(net);
 
 	/* if an IPv6 group was replaced, we have to release all old
-- 
2.43.0
Technical Details
Message-ID: <20261122222717.126333-5-dsahern@kernel.org>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368858-linux-kernel-netdev=dewy.ru
References: <20261122222717.126333-1-dsahern@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368858-linux-kernel-netdev=dewy.ru
From: dsahern@kernel.org (David Ahern)
Newsgroups: linux.kernel.netdev
Subject: [RFC net-next 3/6] nexthop: factor out nh_has_f6i()
Date: Sun, 22 Nov 2026 15:27:01 -0700
Organization: Usenet Network
Message-ID: <20261122222717.126333-5-dsahern@kernel.org>
References: <20261122222717.126333-1-dsahern@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3737505"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:aweyLatcucD2wyVjf7ZAox1AKw4= sha256:G8OhUAfS2w0q3SJbSv+d+gBoG2vmNmj+QsykZwSTCww=
	sha1:VngYMuugHxawU69GU9Nb27J8eq0= sha256:VoI7B5nWJZIlNji3itA9QivdvvJuhG2PRKiW825rGZA=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id C7A3C125D8B; Mon, 23 Nov 2026 01:27:49 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id LqW5PAuc8di9;
	Mon, 23 Nov 2026 01:27:47 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368858-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id E492C125D88; Mon, 23 Nov 2026 01:27:38 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 869282922C; Sun, 22 Nov 2026 22:27:32 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795386446;
	b=hMXD7LO904MXrs54qGXYJylgnBpkmboqoVVOfnskQMcmNFol0Xem3/RzjklS1D9NdrzE
	 0UU6dxdtgzZdpfmHxlq9polDDqD4jEoDinVuT1cMWEQAflb3HxhZLe3JSpHfrRB+RS038
	 y7nf523N+Xk5iWWy2ieMuHrxZD6hsZeTU7OThug8Rm+9RcMMZ/3Y/QO+b/XqOgo663N/H
	 yDCoXRN3F8CL7z5jFhZxvvR32bYy/rme0v6GbpOi1B4VC1hRRxzYVjZjgoIlYNH2UB2aa
	 Njj8ObBoIEW6W2UQGsA/O6zHPWbrBT6bPUJpx8D7c8iDTuuwyq6QRdtdscz7iA07V/Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795386446;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=2WZffXl3jyJwMwq1Py6aVFOiURpXuHsFngoCMEWO3L8=;
	b=JSbsmf+c7QSXhpTNS0v7pOfY4TTD9CCA+G5mZGExRGh5ed9W2gclGvz6K+08AFAoyCn4
	 bBqc5ei8rXCKoqa2qjXRxZpVUvYrmzyFzu4bJ7uHf3WlPchvFzscVtwiEqRv8z4laxkZ8
	 +4nyRDV5nzxTkJ4B1mhS8F5DcLL6s9qlsGLfvbc0aDtKPId0qjMHocEilusewwWkP24Ns
	 trX3FCCU8bBYyuRw5Q392E9bTxrbHDHe/j2FF+3rF10VOhXKoTzhAviWP5rj3pWkOPmWi
	 IJDpAIZlJZ7+arCg9WH5IXEWVk7pcJrZvZIngE9cvjM1hTzFkI9PGBjUEAykZvJ6+/w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i+85ME+L;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id A61C3606A697;
	Sun, 22 Nov 2026 22:27:26 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i+85ME+L
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795386445;
	b=5rlo5S+h2toAWE8klvyHMp0UKkKMQxmnvXp3CWEvVyegP4IPxSuzBthxt4UlEWIdBpaM
	 c44f1hJCgoEIH7UTtYWDAL16aEInvzhnvk0Rne2l5m7TGfvoFVZF3sHjpTTnPwF0hgMxI
	 KBVtRhSc2DnHG4+RiphwuMsl4CbiYokYb8vKItVYH/Lm4cWftKswJGDbR4wuRy9yGG/OW
	 jWhTaMT/2jx+zvrDtYCE1OwxLlgoWNJa2npE0ccpwG+ujOU+WRq5befWFlJoU/+0weFUF
	 HVWtmtF39SKJ2ZcBc3GnRUYRA4g6UhvSMAp8jFi9lMylFIINv7n2RdxRbOaxV4OgHXA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795386445;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=2WZffXl3jyJwMwq1Py6aVFOiURpXuHsFngoCMEWO3L8=;
	b=BEWiFLTl1kt+KkCB3dD/h8VXhG2wk/nlEP9BbOqT7RPSXuPtpEQ/riFsJ/ejQlfLUnTO
	 NM2kOW8nEPmLIAcD3BgiAP6ZAYHyfw9fbzSweKgFeGb/in0PHI4IKvks2Con8u3dw982A
	 Si9X/B/OqVBMJDJwinJLoqpGtoWwncw2uxhHWgF2AJBi8Rn/FnqLamSGinTvyHFSm1YZR
	 QpmhKuOYzg/VIg8Xl6lnN3V7by4jh6gSm4oyuCsxUW9q5N0jPZHKAHwcGikX5qVR+2P98
	 eAey98H4vkzK17sfBJIhpBqqCf88nIZgeCUNxcAb3Dx+oNFx/vPSrU/fbirTDry31ig==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i+85ME+L;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7092606A31D
	for <netdev@vger.kernel.org>; Sun, 22 Nov 2026 22:27:25 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 140801F000F2;
	Sun, 22 Nov 2026 22:27:25 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795386445;
	bh=2WZffXl3jyJwMwq1Py6aVFOiURpXuHsFngoCMEWO3L8=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=i+85ME+LacJSbtEWCRFts2exPWeFai6+QxAaMLYyfsrDnSsBsgWWp3mXam9Hljg+y
	 TtyFRMNLwG5tcGUb38nhnJ5ftGeKhbBROh0VWOHeRdNlyFkK+fWIcIPkNcaPg77bsH
	 CXISjIxGAs30yplOI4TM67stKPY7BOZCffG1Id7mqp+vYNZm1+Z4wCGekLfvku5xqJ
	 iHyNziIfjSAm1/z5kENMYFN2xXXGC+JkBa0uGMT4xYFdar0kzilV9FoyGrzxfDfmWl
	 eluseu0zxVioCOF7a/towZcroBsN5EnX/KXqhNpyS/homh4ETBWCv2X6l3O1COBnA7
	 BtXltMCHBXqdw==
X-Cc: ralf@mandelbit.com,
	David Ahern <dahern@nvidia.com>,
	David Ahern <dsahern@kernel.org>,
	Ido Schimmel <idosch@nvidia.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	"Claude Sonnet 5 . 5" <noreply@anthropic.com>
X-Mailer: git-send-email 2.43.0
X-In-Reply-To: <20261122222717.126333-1-dsahern@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list