Article View: linux.kernel.netdev
Article #20333Re: [PATCH net-next v4 3/4] nexthop: release cached routes when a nexthop leaves a group
From: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 03:14
Date: Sun, 22 Nov 2026 03:14
143 lines
13149 bytes
13149 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] nexthop: missing rt_genid_bump_ipv6() in
remove_nexthop_from_groups()
- [Low] The new block comment in remove_nexthop_from_groups()
(net/ipv4/nexthop.c) says "Routes through the groups can still hold…
--
nexthop: release cached routes when a nexthop leaves a group
When a nexthop is removed from a group that stays alive, this patch makes
remove_nexthop_from_groups() release the per-cpu routes and exceptions of
the removed nexthop once synchronize_net() returns, if it is IPv6. It also
flushes the IPv4 route cache once if any affected group carries IPv4
routes.
> diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
> index 42e55b5a755ee..3fccd4f2f916b 100644
> --- a/net/ipv4/nexthop.c
> +++ b/net/ipv4/nexthop.c
[ ... ]
> @@ -2130,6 +2131,20 @@ remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
> /* make sure all see the newly published array before releasing rtnl */
> synchronize_net();
>
> + /* Routes through the groups can still hold dsts cached through @nh,
> + * which are only released when @nh is freed. Release them now that
> + * no reader can pick @nh from the old groups any more.
> + */
> + nhi = rtnl_dereference(nh->nh_info);
> + if (nhi->family == AF_INET6)
> + fib6_nh_release_dsts(&nhi->fib6_nh);
> + list_for_each_entry(nhge, &deferred_free, nh_list) {
> + if (!list_empty(&nhge->nh_parent->fi_list)) {
> + rt_cache_flush(net);
> + break;
> + }
> + }
[Severity: High]
Does this also need an IPv6 genid bump for the groups that carry IPv6
routes?
For a route through a group, ip6_rt_pcpu_alloc() records the current
rt_genid_ipv6() in pcpu_rt->sernum. ip6_dst_check() then takes the
early path for that route:
net/ipv6/route.c:ip6_dst_check() {
...
if (rt->sernum)
return rt6_is_valid(rt) ? dst : NULL;
...
}
rt6_is_valid() only compares rt->sernum against
rt_genid_ipv6(dev_net(rt->dst.dev)). It does not look at
dst->obsolete or rt->from.
fib6_nh_release_dsts() calls dst_dev_put() on each per-cpu route.
That marks the route DST_OBSOLETE_DEAD, points dst->output at
dst_discard_out and moves the device to blackhole_netdev. Nothing on
this path bumps the IPv6 genid, though. The group's routes stay in
the FIB, and __remove_nexthop_fib() only walks nh->f6i_list, not the
parent's.
In a non-initial netns, as in the test from the commit message,
moving the device to blackhole_netdev changes dev_net() to &init_net.
The sernum comparison then fails, more or less by accident.
In init_net, dev_net(blackhole_netdev) is still &init_net and the
genid has not moved. rt6_is_valid() keeps returning true for the dead
dst. Wouldn't a connected socket in init_net then keep that dst in
sk_dst_cache and silently discard everything it sends, instead of
failing over to the remaining members of the group?
The same missing bump would also seem to leave uncached routes
through @nh on rt6_uncached_list valid. Those routes are in neither
rt6i_pcpu nor the exception buckets that fib6_nh_release_dsts()
walks.
nh_rt_cache_flush() handles the replace case by checking f6i_list
under the lock first:
net/ipv4/nexthop.c:nh_rt_cache_flush() {
...
spin_lock_bh(&nh->lock);
have_f6i = !list_empty(&nh->f6i_list);
spin_unlock_bh(&nh->lock);
if (have_f6i)
rt_genid_bump_ipv6(net);
...
}
Should the loop over deferred_free also check
nhge->nh_parent->f6i_list under nh_parent->lock? It could then call
rt_genid_bump_ipv6(net) once, the same way it calls
rt_cache_flush(net) for fi_list.
[Severity: Low]
This isn't a bug, but is the comment accurate for the IPv4 case?
The comment says the dsts cached through @nh are released here. That holds
for IPv6, where fib6_nh_release_dsts() flushes the exceptions and drops the
per-cpu routes.
For IPv4, rt_cache_flush() only bumps the genid:
net/ipv4/route.c:rt_cache_flush() {
rt_genid_bump_ipv4(net);
}
That invalidates the cached rtables, but it does not release them. The
rtables in @nh's fib_nh_common (nhc_pcpu_rth_output and the fnhe
exceptions), and the device references they hold, are still dropped later
from the RCU callback, through nexthop_free_single()->fib_nh_release().
nh_rt_cache_flush() describes these as two separate things. One comment
says the dst entries "need to be regenerated" (the genid bump), and another
says "we have to release all old dsts" (IPv6 only).
Could the new comment draw the same distinction, so it doesn't suggest the
IPv4 dsts are freed at this point?
> +
> /* 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);
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117-bug-net-netns-move-rcu-barrier-v4-0-43e1ca0aac7f%40linux.dev
Technical Details
Message-ID:
<179531725321.3135.3845475174656034580@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-368570-linux-kernel-netdev=dewy.ruReferences:
<20261117-bug-net-netns-move-rcu-barrier-v4-3-43e1ca0aac7f@linux.dev>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-368570-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v4 3/4] nexthop: release cached routes when a nexthop leaves a group Date: Sun, 22 Nov 2026 03:14:13 +0000 Organization: Usenet Network Message-ID: <179531725321.3135.3845475174656034580@kernel.org> References: <20261117-bug-net-netns-move-rcu-barrier-v4-3-43e1ca0aac7f@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3558077"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:aZPBl5J5PaQigrU4BOcXRZU7UCM= sha256:ip7PJoKc7vxsRKuy9MnHUmbJsKFdNtm8mtm0C75V0YY= sha1:bDrEqfx+73FG11uE+K/sKh/JdFk= sha256:hZz920pkDT2WXASME1WyFRniUZWFts/zs6Jsx+oQhLc= 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 7238C115C68; Sun, 22 Nov 2026 06:14:41 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 Omf9KifMgXvt; Sun, 22 Nov 2026 06:14:38 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368570-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 B50B6115C6B; Sun, 22 Nov 2026 06:14:29 +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 D738237DBC; Sun, 22 Nov 2026 03:14:18 +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=1795317255; b=Jr/ND8DsMfFe3dMDX93pCC/epsuiXGnVkeclhJacHoBMMbCyxIzWDlkG3Xz6x2tp4z3S TqQBOEuNpgklFp/dyHSdJACvMemDYY3goyje2Loo8qs/y+qRoK1wXFeZGJVv0AhlONI66 AHBA6xtGRoPj6QoJ7Nm+drucYPV1t9Rzz4nSuALUZOBJoQD9kYBsr5B05J590u1k88vxI 91RdBNndvrA36QrqFYmm++06Yb/ouDUxC+xBVK0ciPECfvkAvh77n3S+olJ3A0IEAeEcu 1yE+pqix8c6MswHqMBxlYD9/s+Sv9XvWagkb35zinyp0StHIRn3EPuHrZYExHdhPR0g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795317255; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=MiHnBCHWuGCXIjnf+5r31E/jBmeDF1IrNB3zfS0Is7Y=; b=ANIO9BjrpesC3p0MihVNEC+mqsyhHquoNMo+SAiMjHpocyHS7JAAkBZnITq9aH7wt1jn OEZv2s+Ecg/O1MlPteWpuL2hw6FlDxhzI16+SE4nWNwg3oXTr73/9WJA1Dxm+dlyNOkUx 3lCgv8SijGbSGLoJ53Zcfn1xLyVOwAxOhWzTonITTiAWsBxxwie/w1PofnvsuzT87MyG2 h6s716z0D371PPztP0DRHx0A2Qs4LPKaPHWHtaFEuUaAQ670GvKdOmgK2Y7R1UWmaeOqp Zva2gxagy3qdGWo/6MhmZKxF5COVvDnshJSNxhp4NoiT8KpvyAh0QAKrAjj845QTDzA== 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=dGTk69ay; 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 60C04606A6A0; Sun, 22 Nov 2026 03:14:15 +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=dGTk69ay 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=1795317254; b=p32C7frmcn/p/UOpBcV3U6sW4ecBfPs2FJ43lX3ZF6NoY+UkiG7KLskPu0jgtUiLIzpX PXDytiWYKYN1S49cnDt4W/XqAQEmK3F5qA5OVr4iXFVYZp7CpauHvvhISsVd7R/XDj41R RKLp0Csu+VOiBl+GEeNREqgGag5fTI/nH1oFU78L8tnukUpnTtYg/qqYhsEw3AEapl38W KKpBVslsQqMU0fsLQpVXPUPSs0TDW7LLu1MvfzIzJbRXuuwHakyvwldZMXtcIQu4kudvo oM1VmDH4e/SYTxaYTABvI87Tn1Mhs/h3DqW/eos6l8vYVnfpdk0Gpb+EkMMxBZY1IZQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795317254; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=MiHnBCHWuGCXIjnf+5r31E/jBmeDF1IrNB3zfS0Is7Y=; b=XEsQS3YDfiq1C1tC6l9pKmTSvC2Q2QAr7J2NnF3mvCTJXezZf8WcUkdPB7Y2BkP/zVz/ rBOhq1OfuaOClV5mpbgBWqM/PR4DHZdduAynv3GUon2EGS6wt6ZF/S+wLIQ3DbF+Mt9Qe JCDY8zAN0uP3Lbh627pPuX2URiyfpe0ECcOFld79Tc67ydOtLg/ofkDNKm7tEzZgSyUO7 frJWSFLOCQPKLExh/GhstL1uUckgaW4ABh371GUiyWvYC7+Z0qMqQs4zXB2G39tunq3E4 K/gHK8PFZ3Iyj0t1djLcj8Y30p/vJXew3+3hUNeWb5LRbP/6+RDBGDcBjScTjg3DPvw== 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=dGTk69ay; 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 834EE606A690; Sun, 22 Nov 2026 03:14:14 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BCD71F000C0; Sun, 22 Nov 2026 03:14:13 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795317254; bh=MiHnBCHWuGCXIjnf+5r31E/jBmeDF1IrNB3zfS0Is7Y=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=dGTk69aykAgsofnN++pYnu7DiiGK7OlWFcb3XRPELjfAjMp8Iqox5rKtNuHRvApme 7T/T9utC8Dkh+3KwQxbQxJXlI8IvmlTTAzYdCnpQLFTEW+Wz6nueTo2A1L2NmA+g1c /t5Yi1CVgS81QMos0kWMj1iinryJBJbHNn0wkdYf4inUFWgFPrAEgj7AbwVWQFeF5w FX8b5u/MLWzAiRuZwIAXyVOvP7pxJ89A+98SDk3c0lK749LU87IlyCNLFfDsniQJTB 85hfhLbnefeg/F2xkV6qvjQWNpYyZZ9AD8+31Yvu/Rx7wlpuyB2ek6VKsLLQhfuAtF /95JToKExNmLA== X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, dsahern@kernel.org, idosch@nvidia.com, razor@blackwall.org, kuniyu@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261117-bug-net-netns-move-rcu-barrier-v4-3-43e1ca0aac7f@linux.dev> X-sashiko-severity: High 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