Article View: linux.kernel.netdev
Article #21320[RFC net-next v2 4/7] nexthop: bump the IPv6 route generation on group changes
From: David Ahern
Date: Mon, 23 Nov 2026 21:26
Date: Mon, 23 Nov 2026 21:26
90 lines
10430 bytes
10430 bytes
From: David Ahern <dahern@nvidia.com>
IPv6 dsts are invalidated by bumping the netns route generation, but
two nexthop object changes did not do so:
- Replacing a nexthop that is a member of a group only bumped if the
member itself had IPv6 routes, not when routes used a group
containing it.
- Removing a member from a group republishes the group array without
any bump, so dsts built from the old group stayed valid.
Bump in both cases when IPv6 routes use the nexthop, directly or
through a group.
Signed-off-by: David Ahern <dahern@nvidia.com>
---
Changes since v1:
- None.
net/ipv4/nexthop.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 53431fe7d328..7cf496589f4f 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -2120,6 +2120,21 @@ static bool nh_has_f6i(struct nexthop *nh)
return have_f6i;
}
+/* true if IPv6 routes use @nh directly or through a group containing it */
+static bool nh_used_by_f6i(struct nexthop *nh)
+{
+ struct nh_grp_entry *nhge;
+
+ if (nh_has_f6i(nh))
+ return true;
+
+ list_for_each_entry(nhge, &nh->grp_list, nh_list)
+ if (nh_has_f6i(nhge->nh_parent))
+ return true;
+
+ return false;
+}
+
static bool __must_check
remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
struct nl_info *nlinfo)
@@ -2127,6 +2142,7 @@ remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
struct nh_grp_entry *nhge, *tmp;
LIST_HEAD(deferred_free);
bool need_flush = false;
+ bool have_f6i = false;
/* If there is nothing to do, let's avoid the costly call to
* synchronize_net()
@@ -2134,13 +2150,19 @@ remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
if (list_empty(&nh->grp_list))
return false;
- list_for_each_entry_safe(nhge, tmp, &nh->grp_list, nh_list)
+ list_for_each_entry_safe(nhge, tmp, &nh->grp_list, nh_list) {
+ have_f6i |= nh_has_f6i(nhge->nh_parent);
need_flush |= remove_nh_grp_entry(net, nhge, nlinfo,
&deferred_free);
+ }
/* make sure all see the newly published array before releasing rtnl */
synchronize_net();
+ /* a group lost a member: dsts built from the old group are stale */
+ if (have_f6i)
+ rt_genid_bump_ipv6(net);
+
/* Now safe to free percpu stats — all RCU readers have finished */
list_for_each_entry_safe(nhge, tmp, &deferred_free, nh_list) {
list_del(&nhge->nh_list);
@@ -2264,7 +2286,8 @@ static void nh_rt_cache_flush(struct net *net, struct nexthop *nh,
if (!list_empty(&nh->fi_list))
rt_cache_flush(net);
- if (nh_has_f6i(nh))
+ /* dsts are validated against the netns route generation */
+ if (nh_used_by_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-5-dsahern@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369781-linux-kernel-netdev=dewy.ruReferences:
<20261123212623.106153-1-dsahern@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369781-linux-kernel-netdev=dewy.ru From: dsahern@kernel.org (David Ahern) Newsgroups: linux.kernel.netdev Subject: [RFC net-next v2 4/7] nexthop: bump the IPv6 route generation on group changes Date: Mon, 23 Nov 2026 14:26:06 -0700 Organization: Usenet Network Message-ID: <20261123212623.106153-5-dsahern@kernel.org> References: <20261123212623.106153-1-dsahern@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3988564"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:IPFWnhpbYQ5F4EgWwm1Ui6P9mnI= sha256:l1r/JnQeuRRcu4g4ZFgzK52qjXnC7hq26N5FGJLTgd8= sha1:W4KT+QUSHEQEer+wc6kRuwe5UEo= sha256:BEyKOqSKIZKki3UfIr6abUs7EIWDcebl0CyFr9LnWk4= 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 60FE4125DC6; Tue, 24 Nov 2026 00:26:53 +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 j-Y0KIPpAVUK; Tue, 24 Nov 2026 00:26:50 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-369781-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id CE032125DC9; Tue, 24 Nov 2026 00:26:39 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 6650327DB8; Mon, 23 Nov 2026 21:26:35 +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=1795469192; b=lEZFzD9V2c0UeLYpG7VZmHBmXy2nzghnkZdC/f8KKQXG+Tk5ZGON7u9ZpJnmXko/+Dhs nNe2K6uFe1qQFKGH+pW7doS5EG6HN9gbxf4Ufm6PUBGseJE68sBvmpwUq1px4ugAuD2hK fKoCU0Si7KFxzj9Vp4HUbQuJhMLOfIkR/yyGGfyZ/ydQYQoPuVnsd9e66fBfIt0UqNLOU M4rYNdJqBTgTagTCYo7ZoQZkiqHFLWxhPA7HwEoyt6TfcHYJj2TmBeI51xzbEiE8CAg1R 8WXWr0bEhl4jsTsaloMnbkAKqm40WHZdHYg2z0I2ykF4PPfl8uBnE9jS/jZyCh7DJKg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795469192; 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-Type: Content-Transfer-Encoding; bh=ivyQkRikRive9LW/MxJ4L5A8kdukFsnKV4O0WgPaXnU=; b=wUF4AgWmq6W06Rk1HAwth2Tqg5/QI+NZTTWI0QhGdHVkqVZfuwob7BqLK88pPTF0obiF b7trqmJ/xYhG3iLKOFwj0f7CBYgJC+OanH4bDNQig3McDgkgbLNWWsy9mPrx+kfpVioMU p6Qipl2m7eos+YQevpdwZeeGthsXoVO4aF7CCOVOcHUXM5ie4mvELEn4QC1pgxt0ltOCN i/MiRRrcdWJIXX0iwQHREiUPBTTeYBYnASimRxnCQv4QI6IfrRdEbj+Zo5RkX7YBSplpb LbofjEzXySduvDlEEXhvXYXlBD1Udcasv0QKjVamkPagtF7PIjuy5jHF/T0uarBytTA== 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=iLIKwPip; 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 794B1606A693; Mon, 23 Nov 2026 21:26:32 +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=iLIKwPip 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=AkRETkfwSXAwFhqzIVg5yAAeMy7Y/s9Zre3qO0gBgKxLTh34jR2cJlSOl5y4ZJUDgFeD 0zTjH0nI3GXoRUPTBP1RoAMfSF4B0BGoKAP8MyimLA0GL5z2ybYE42QgkarVB+4Tfy2MJ 5drHgZ2pweQH9/PUkLohmI+tEV33DVvwbmFa+S4Dl/+6tW8HXv5sC4lArzmzCri5fXn9m +xqaYMbzrr4/N6s0luFundr/FhC+vJLDDxjjx7VirOnzv8XSFebZaT5TYQfggQNCJB1xy +Tx4yLMFRUKMWjSQDnRvQWLHshGWBTEfjqHwfPew8QUGMyb5442p4W2Rt5a9GuX0Bnw== 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-Type: Content-Transfer-Encoding; bh=ivyQkRikRive9LW/MxJ4L5A8kdukFsnKV4O0WgPaXnU=; b=Xl4JiAXOiaTwXZc8QH64tbbIA/FGHJHoHlwNJxIbz38SFFn+UnwHSu8OgruyMXH5P8TA odnC+FxbSn8xqM36prPPgKO2lI8FbeAJFa9Wy2HcE1QuyiethV914zUGysnAB79lv6I5Y MmKg4M6qSWtmvoKPaWF65ToJq6XB5r3uZtbKF9xTnd6ngCvQbLKPtXojo7wKWniw25XOB XEG5WRVFwzFntE/F+iyf7OP5+T1oxSPdFDDGSktwTTboVmv3sc+jNDXIrlBCyPxFu+ZBW KmEEFXsbGSHiDQDlm2bOCRRJcXeSmgDarI0AwUlhsidpIjN5F1BX7QkkN7qs6ZPnh1Q== 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=iLIKwPip; 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 9AE64606A685 for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 21:26:31 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBE771F000E0; 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=1795469191; bh=ivyQkRikRive9LW/MxJ4L5A8kdukFsnKV4O0WgPaXnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iLIKwPiprtSDNtFBTaf8afaiJ9l8V/RUuDrG8Taw4Hv2uzqQTTtEJSp3girSEheG5 twqnNuKBijKEs1qImib/ghrdxJ1DHAHZjZCUGDnhBpndwUBSKYJc6p9Cc7qdrsIZ6u ZHm5/KHMlVx2H0GyeNJSXVcOo9E3sKHsGvWHBzQy+kTYJ/TAFS6Iord6SbH/3rXYgW 3HDuDHcB23fvckN904zPBObD37dI06TMBwjtaOSZ1ardhp7ZIO7kYIO5N9Eh2uc+HM Dxa8MsQoGs22dl+7NuCV4lYTNsoIXpwhgqA1SsM9lzDvXZvgTMgHaD2xOdf67ma73i NTAmJi1sZ/Cdg== 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