From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796146864; b=eddlQCDGq2dy5b5eaLOWuAGs0mEG8HQheQ4NiR8pjeFrixl8fXwg2d+kkQbJAGWr2Kau 79swPFmxzWtzv2ikf/p+FYM80wzGVDLvJ4co7gSVue3yez/QraFRQ+Q/1Xu7TNQ2Sj88v MSFPTXycp6D8ZswdJY1cfHzI2SB1S2C05E5yPXU2ISTTXsRvhccFEU5lEMWmnPUrdL/5x sR7gQjPO5Uy5ACdUM+4gnCrrDbC6y/akN67J2cKHODS7uQnxNeZb4pg6GcL2qX5f+gDTR KomWBIGZk8k2uXpVSVrcmmviH8JT9+viFLufaEQ1IMmXjIPXLBTaEqHkcIX4/8Rpjjg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796146864; 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=49rKa6qOEwzJBeO+IrIoA4pm2njSfCUMlYlVq+43bUWUCdq38YnAOG/ZCXx7a4rUBcrG f6mRVJrs5CPgsXBRWPfXs5YzJA6V+s/Vjq1uDzMa/8+1ytkskePLV8ddLiXUM/DvnZP+u C03aNfBmqsStqnWnIXFbgkR/MEZZcysIXgbHWGZhMlpeG/gXyYcbR+8ebSvg3WapuYjRu WkEpIR55xGznlZOCVEvJVRTpee7IUbYthlMrIGismzIzJF/ljEUeVFhkgQOZW4GJ4CyKr 8A4fjFw8tL6Ije2AREIzuB9lrDK3zepdRpFW07JDKOy9DG6u90DQkYGVnQ/LQHuicgg== 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=mIckeiAX; arc=none smtp.remote-ip=100.103.45.18 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 CBA64606A6AE for ; Tue, 1 Dec 2026 17:41:04 +0000 (UTC) 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=mIckeiAX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 255031F0093B; Tue, 1 Dec 2026 17:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796146864; bh=9VyDZEv23BvcX7vVp78Vi/R/LVAtah78Cem9kFMvUnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mIckeiAXPPybMQpMLonjWEAuEYY+sMZCc+BhDDQD1sdqhhfc5c3CnHkV92icLrBCr fYhun7pfJbYY41ROEOPdDF4/HcGDHKaj9FOXigYxAae23U+Ls9F5tbExnvNa1d2Hgo +3An5DYm+ASwhl4gQ8h7MAEE42v7Qj1ZQPmNUT1tpoVX1btHTotJ+f3dbKp5nZVSlu cdhmuo4qyDgDv46iDuWCvCRFvWkijkVRRJVB4d3u0AJDe7D44kvuw3TMvsg2u2EbZV gUEJ2ORT55zswCrA+NzOsljqWQuFTNxqDjyfeGXCH0kPa93w3AJmB9TbC3nuxHuz5T 990ouU2+Jk3Uw== From: David Ahern To: netdev@vger.kernel.org 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 Subject: [PATCH net-next v3 09/13] nexthop: bump the IPv6 route generation on group changes Date: Tue, 1 Dec 2026 10:40:10 -0700 Message-ID: <20261201174021.7211-10-dsahern@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261201174021.7211-1-dsahern@kernel.org> References: <20261201174021.7211-1-dsahern@kernel.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: David Ahern 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 --- 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)