Article View: linux.kernel.netdev
Article #22838[PATCH net-next v2 09/13] nexthop: bump the IPv6 route generation on group changes
From: David Ahern
Date: Thu, 26 Nov 2026 01:33
Date: Thu, 26 Nov 2026 01:33
87 lines
10634 bytes
10634 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>
---
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.54.0 (Apple Git-157)
Technical Details
Message-ID:
<09d703171e31f488d7015349516203e8196ba843.1795642432.git.dahern@nvidia.com>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371792-linux-kernel-netdev=dewy.ruReferences:
<cover.1795642432.git.dahern@nvidia.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371792-linux-kernel-netdev=dewy.ru From: dsahern@kernel.org (David Ahern) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v2 09/13] nexthop: bump the IPv6 route generation on group changes Date: Wed, 25 Nov 2026 18:33:35 -0700 Organization: Usenet Network Message-ID: <09d703171e31f488d7015349516203e8196ba843.1795642432.git.dahern@nvidia.com> References: <cover.1795642432.git.dahern@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="353191"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:6JA/bHJu9zeXBW1MpID5MAKj5BU= sha256:d459TjTafACzYeLY23eLNwxmnU8Z1c2xy9CviugcUow= sha1:DAiHYdMJfyQmwmMlaWnF1qrI4PI= sha256:P+1De2x5tRuqjj/GsoIOTJ5QLgixrFGjWLYLEvmuf14= 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 2EFFB125EAB; Thu, 26 Nov 2026 04:34:20 +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 mTlOvWCBmYXI; Thu, 26 Nov 2026 04:34:17 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-371792-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 C5FC0125EB2; Thu, 26 Nov 2026 04:34:02 +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 39D2833E5E; Thu, 26 Nov 2026 01:33:57 +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=1795656837; b=uTbCcMbv6IpG01W2odULZIzbbgGBD1BGqxD7d+Z01/vZ3pRsStVyYAgS5e1hzHlkFvHQ Baqg9dSZQzfOMBvqR+U5/WcejU0UU8KO3ne6aT6urpeC454xk1vAnanFYa3uRmJTPvrLL x7sqCcl4SrRc3joLSDkcd7T2rXqKhF/VVmmHH4QBXiiwGJWRK/P7xrgoezyUa/SCLKj6Z R2QsfrqieLOfALkMr2o66qPCauj2vabxbTj61Zp4eJHo9aRMH79KxP4qGNRx37gkYrpaI Fe1oiOr9VJEMERS5sqGcVbQTMFE13QlLLVw9zIApqFfe3L46Lpwfp+qqINzdXXeO90w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795656837; 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=9VyDZEv23BvcX7vVp78Vi/R/LVAtah78Cem9kFMvUnA=; b=z4HyAqiFx7kXkceH6KkhSIeG+T9DdVAYYoc463IYHURGT+nse5Oz8K8hXOSKotmnbOmI KDB8mcI7Vr7zOLvpbbCHe9/LFyOpJWHVsp48MFCS8jRIhJBUZEvWSyMt1+mp8JLjugqYq y5JStYksWyyg1Nvr0ht2cdziYzLQkvaGS6zkUYxFv0ZN+2YQTlwsNFY5zg90zaSGoJmRw frheKPqZl6rBMll36JwNfmDi4pP/zdUdtS4LQyV6QujqTSBK6p0ylrztRPgMg5CMzkHSy rNdIajPCECMQnCK2D0T8I0yfgNQ/VRjck4sJ4pWGvqFGtMkWFqx1vg0XRyEIsfO+JZg== 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="g5/PeLPd"; 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 F280D606A330; Thu, 26 Nov 2026 01:33:56 +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=g5/PeLPd 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=1795656836; b=yZIya5tPqr8Vy9yG7J6ec2BhBdlAdyIi10gYigazkkk5rOGz14uwWbtQyI1v3uNPGK6Y VEz1Beo6Et+EY+z4l+aYJq1KreE2gwAJqdhFgBqHtdquP+cAgpOSNKUbatjjcqQO+GqiF LRhZ/+ryoIlSDxDVIC7KGKarax5gU3lFvmxa5m5ARxIRzf6rfWPtSQe/EQUVYJrgENZ7+ r4mWRdQzxuvfsaZseLkJD5X4tvpzIYSdzmVlTfl/IToA6QnTPom/rrWsTnIVIg9Z2D1qt Lrm44UTz5PcMa092CKC9B2PX4MsSok6cjZ34PNlNXPJ2WSFlQsO/2aULGt1LUEa9fNg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795656836; 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=9VyDZEv23BvcX7vVp78Vi/R/LVAtah78Cem9kFMvUnA=; b=jUrfbmM2Bs49yVC+pPT66XymAHJ85Jh3T3WP9Ppp/Ugv4r2M03P1wt7vK66EOqmyJuNg 6EmY+0V74HtyRR0AjiPKsqFVviwwx5xHsveBfVj+M0v8jvAYxOdJPiNdg18R4+lNGtW/a PP8a1eC2LfUCjiZoaUnqMPohGFkOOZ+irgNi6MgqULb2c1T/ersSiiSFxIArdQb5vkqhv 0ku5xFlRql/DE4+tNeOAXBe4oWeqVdKrm5Zon5UcW2hjzJT4avalw/oMnzF0RnFE2+Yce Qs6LRGu24QE3k4UMUlo738REbXeed2OAyopvznwJfW2pbV8S2zer4E9pgtmNKt2FRvg== 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="g5/PeLPd"; 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 1DDFF606A32D for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 01:33:55 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AEEC1F000D4; Thu, 26 Nov 2026 01:33:54 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795656835; bh=9VyDZEv23BvcX7vVp78Vi/R/LVAtah78Cem9kFMvUnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=g5/PeLPde9tCgraBxPqIidaCCykxokG1Om3bZhfud0FyIOjPqK+q4xMAPBvqZnlrE /IFQDt7GT/uyswwAH02jwl476PmpB3av4G+C2NGzKBzd4FYlicurpbibbqsTQIpVJA rU/ZRAmZqqM72tUthglquNjjLBMG4DaWfudRoqmBRsLv9Q6YMSWotpASJC/3LpMkV3 KtiFH9mGVXW1/2pCtKK9Mpx3NZZ/Hzm3G7aJKRcmhWtVNYLSvUp7mmDQFGntyEu95B WYN9o6j13N6Whg/pXOFOm8HQy9Dq/60s2YCBtsb9oYqLYTl4XCXw8pOAAQf19zfnOn CCkWzflEqM7Hg== X-Cc: dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, ralf@mandelbit.com, ja@ssi.bg, David Ahern <dahern@nvidia.com> X-Mailer: git-send-email 2.54.0 X-In-Reply-To: <cover.1795642432.git.dahern@nvidia.com> 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 X-Received-Bytes: 10375