🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21321

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

#21321
From: David Ahern
Date: Mon, 23 Nov 2026 21:26
60 lines
9013 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>
---
Changes since v1:
- None.

 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: <20261123212623.106153-4-dsahern@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369780-linux-kernel-netdev=dewy.ru
References: <20261123212623.106153-1-dsahern@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369780-linux-kernel-netdev=dewy.ru
From: dsahern@kernel.org (David Ahern)
Newsgroups: linux.kernel.netdev
Subject: [RFC net-next v2 3/7] nexthop: factor out nh_has_f6i()
Date: Mon, 23 Nov 2026 14:26:05 -0700
Organization: Usenet Network
Message-ID: <20261123212623.106153-4-dsahern@kernel.org>
References: <20261123212623.106153-1-dsahern@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3988613"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ojbr38K8nOolt99j4IZqi3BU8e0= sha256:wNfUmX/qLEhX1ZGcLKgA4ej+iR6rQ/GY0vupPBFxg4I=
	sha1:Dqt06GPYZ68mp+S+kn0C68aXPds= sha256:osg8Ce6QgULVMmp48vdIIKdhrxeY/k2MWiXIo8BojkU=
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 D9E09125DC6; Tue, 24 Nov 2026 00:26:54 +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 IHtxkly0egcZ;
	Tue, 24 Nov 2026 00:26:52 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369780-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 04CD4125DB9; Tue, 24 Nov 2026 00:26:42 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 2F1A037434; Mon, 23 Nov 2026 21:26:33 +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=1795469191;
	b=Ol8wNtnS+T59OMz8zAoqqVK7ORVG9AmFveV6eC9UWtFfCl7DcdXRuFOZnawr1sydB1ZQ
	 pZoJM9F7lI+OMNx3GNKZ97h+EM0iVfbiI0ZlBhNhTdFo/W12DpFfwMuPLLrsY83A7xTtw
	 Jy062NROkiTCfNRQRs34lFEFeyprN6252I1Yhrc9YELYSk+HK0HEfYN7G4kwaGVzwHYjJ
	 ztgwyTPJrPWTeRQktT1UrrFfaAdl+CnjkCu4HtBP94ChAV4CfodU06vD5YJQFs40e/k7Z
	 X1FKbGtXqMNi2NkGXmUb19OHiiLS7RCd4YdYM7BfOQ1JKy2UV0bQxlFqNV6XXK9IknA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795469191;
	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=Ys1I2/dqjY0C2V3gDyaRjkeFYxfNTPPitZA6zoLDPos=;
	b=s6pa+bsgmDL0SU/UTehgfjz/ezbcA24H7KXFvPPPUkfVUbMCIdz6WOQxb44fOZaV6Vki
	 c3bIeHTko62IkUigeCul/6DzM0R6pjKbECF2jDsO61sGV4XZp/0kbyeim4adsTvN8Aqal
	 S8DjIGxMWz0JXQ26zRZbVcK7u7BjOP0ggu2HSl+K6r1swZOVDzE2PgV/xaOU56D+sATeo
	 2g3I0ruDCMyx6mNSfk+3K79yAVw6tyTq67jyMUQapLHw/CoLd0RSUa5LjnWLTnqeKIlyJ
	 YHot2+qIMMaN7fI75IUkoDB95UxivHFwAYfr18vxqFCotsIk+mWtSA9D0iQpKv+OWQA==
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=AN7VXyl+;
	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 C5EA2606A321;
	Mon, 23 Nov 2026 21:26:31 +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=AN7VXyl+
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=1795469191;
	b=e3eEEFfKgiNdl50tBrsHrQB7dkriY0nk0iCRX34jAfJmuN8lSQZHsWL/j8Mm5Io196o2
	 1kWkKe6DxQ4uAmJbBskQTfS288WdzpcsDDigC//zyauKOxRqBZTlBGW8Dv2sz8StyeWgN
	 EasnUttE1hEIF5jjzyU/8IOTtb+hnrTPcOD7y82g/8cuwyvgzSc847oGR3rp37GAWyGU8
	 7vIqLYMtqZhcZ8R2fUY77RCP+78QK3NeZZzY31/LO+5zTnCH85HnxbqVO2htzXcvAlxzg
	 +Aaaxl2X/xBKUIFOzvg4ayM6HcmZDtZllz0lApWXLXuGF9rTmMLBohZz5iSuwWayHJg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795469191;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=Ys1I2/dqjY0C2V3gDyaRjkeFYxfNTPPitZA6zoLDPos=;
	b=RXZlNKOrRiz2KVYaT+rBkh5Di3KD6di38wWHHpoFx9axlTjqAAEIU93fy+bjJDiXJvGx
	 lx5GG2cWIkbwOMTNYTg7TXZrfShqAa06Zlbba6GaJmQ+lfzyA5gTySjbENO0wUBVBB0XY
	 NypOvdWnlNAKbj4xdt6WxX44aPpy6nBBJd2SupE0KeHT9Unz3xIsfqNfjPTuwWpPCpyQn
	 SYLPC3+4vFEAS31K/lQ1pkZWUciS5ejeMOEBPtww2mWslnUTuFpmy+1kyWYRthRgFlvEr
	 cKrGp9YoMfeZWmvNrGI1YzD0rJCFvb7z7zEQE5tmwEC46dLK4LtRV/R5zZxeS4DNsuQ==
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=AN7VXyl+;
	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 E82EE606A327
	for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 21:26:30 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A29E11F000EB;
	Mon, 23 Nov 2026 21:26:30 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795469190;
	bh=Ys1I2/dqjY0C2V3gDyaRjkeFYxfNTPPitZA6zoLDPos=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=AN7VXyl+RNZGjVtNGYl52k3s6w4BlqBlxtlf3H657SDV0hHwcgbhWAjRJ8rEK+5sV
	 qdjcqpgfRnIKm5SkHScIkUqqRZKboH/pQxOReEo+DVpSFJvdumIZulA92OGyF4A0vX
	 LFOM5yBokEuMjBw/LBqNMqqFgXAyeCXyxgSR8m8zMJjn5LCJkwuTF/gW9VOEzJp5wy
	 OHz9cDnLzwWSkAjcaNZMigGu6MBRoMDOORrh5HvhVqWPF3aZ4ZVoEFSo3c2iFeC3mW
	 qHah4UxBE0D2RJDMxC+QdU2D8HhvAMD4yB+MePYZ7Q6inzQ9Ynm/XdOGpMpIQQKIhX
	 yxU0yE4bqllpw==
X-Cc: ralf@mandelbit.com,
	David Ahern <dahern@nvidia.com>
X-Mailer: git-send-email 2.43.0
X-In-Reply-To: <20261123212623.106153-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