๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27478

Re: [PATCH net-next v3 04/13] ipv6: invalidate the failing dst in ip6_link_failure()

#27478
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 19:20
153 lines
13629 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท 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).

- [Medium] ip6_link_failure() in net/ipv6/route.c now invalidates only
  the dst attached to the failing skb, through rt6_dst_invalidate(rt).
- [Low] Verified, then discarded under the series rule (baseline
  decision: false).

--

ipv6: invalidate the failing dst in ip6_link_failure()

This patch changes ip6_link_failure() so it no longer writes -1 to the
fn_sernum of the default route's fib6_node. It marks only the failing dst
as stale, by setting the top bit of its sernum. Readers of rt->sernum now
use READ_ONCE(), because the value can change on a published dst.

> diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
> index 232289b439c3c..bfc1895e85915 100644
> --- a/include/net/ip6_fib.h
> +++ b/include/net/ip6_fib.h

[ ... ]

> @@ -315,6 +320,24 @@ static inline u32 rt6_get_cookie(const struct rt6_info *rt)
>  	return cookie;
>  }
>  
> +/* An invalidated dst keeps the generation it was built under in the low
> + * bits, so state derived from it (exceptions) can be stamped with the FIB
> + * state it actually came from. The top bit makes it fail rt6_is_valid():
> + * the netns generation is always positive.
> + */
> +#define RT6_SERNUM_STALE	INT_MIN

[Severity: Low]
This isn't a bug, but does this comment match the code at this point in
the series?

At this commit, ip6_rt_pcpu_alloc() is the only place that writes a
non-zero sernum:

	if (f6i->nh)
		pcpu_rt->sernum = rt_genid_ipv6(dev_net(dev));

Legacy dsts (no nexthop object) still have sernum == 0 when
ip6_link_failure() marks them. So there is no generation in the low bits
to keep. Nothing in this commit reads the low bits or stamps exceptions
from them either.

Marking a legacy pcpu dst also makes its sernum non-zero for the first
time, so the dst now takes the drop path in rt6_get_pcpu_route():

	if (pcpu_rt && READ_ONCE(pcpu_rt->sernum) && !rt6_is_valid(pcpu_rt)) {

Later patches in the series fix this: "ipv6: validate dsts against the
netns route generation" and "ipv6: stamp dsts with the generation
sampled before the FIB lookup". They make ip6_dst_alloc() stamp every
dst, add rt6_dst_sernum() and stamp exceptions from it, so the comment
is accurate at the end of the series.

Could the comment and commit message be reworded here, or this patch be
moved after those, so that each commit describes what it actually does?

[ ... ]

> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 06afb9d5dc2b1..5af0f26332ffa 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c

[ ... ]

> @@ -2912,14 +2912,14 @@ static void ip6_link_failure(struct sk_buff *skb)
>  			rt6_remove_exception_rt(rt);
>  		} else {
>  			struct fib6_info *from;
> -			struct fib6_node *fn;
>  
> +			/* Force sockets using this dst to look the route up
> +			 * again; a stale-marked sernum never matches the
> +			 * netns generation.
> +			 */
>  			from = rcu_dereference(rt->from);
> -			if (from) {
> -				fn = rcu_dereference(from->fib6_node);
> -				if (fn && (rt->rt6i_flags & RTF_DEFAULT))
> -					WRITE_ONCE(fn->fn_sernum, -1);
> -			}
> +			if (from && (rt->rt6i_flags & RTF_DEFAULT))
> +				rt6_dst_invalidate(rt);

[Severity: Medium]
Does this leave the pcpu copies of the same failing default route on
other CPUs valid?

Before this patch, writing -1 to fn_sernum made every dst under the ::/0
node fail the cookie check:

ip6_dst_check()
  rt6_dst_from_check()
    fib6_check(from, cookie)

Sockets on any CPU then looked the route up again. rt6_check_neigh()
returned RT6_NUD_FAIL_PROBE for the NUD_FAILED gateway, and router
selection moved those sockets to another default router.

Now only the skb's dst is marked. Take a connected socket on CPU1 that
holds CPU1's pcpu copy of the same RA-learned (legacy fib6_nh) default
route. Its sernum is still 0 and fn_sernum is no longer touched. So in
ip6_dst_check() this branch is skipped:

	if (READ_ONCE(rt->sernum))
		return rt6_is_valid(rt) ? dst : NULL;

The fn_sernum/cookie check still passes, and the socket keeps sending to
the dead router.

Each of those packets goes through __neigh_event_send(). That moves the
neighbour from NUD_FAILED back to NUD_INCOMPLETE, queues the skb for a
full probe cycle and then drops it. Only after that does the path
error_report -> ip6_link_failure() mark CPU1's copy. Flows whose skbs
were dropped because the neighbour queue was over its length limit never
reach ip6_link_failure() at all.

Is this intended? The commit message says invalidating the node is "far
more than needed" and that the new scope is "one CPU's copy". It doesn't
mention that flows through the same failing router on other CPUs now
fail over later, each after its own probe timeout and packet loss.

This is unchanged at the end of the series. The exception-insert code
added later in the series walks nh->rt6i_pcpu_dirty / rt6i_pcpu and calls
rt6_dst_invalidate() on each copy.

Could ip6_link_failure() do the same for the failing fib6_nh? That would
leave other routers' dsts alone but invalidate every copy of this
router's dst.

>  		}
>  		rcu_read_unlock();
>  	}

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201174021.7211-1-dsahern%40kernel.org
Technical Details
Message-ID: <179649845377.3148.17926604674199917416@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!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!peer01.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-378102-linux-kernel-netdev=dewy.ru
References: <20261201174021.7211-5-dsahern@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!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!peer01.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-378102-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v3 04/13] ipv6: invalidate the failing dst in ip6_link_failure()
Date: Sat, 05 Dec 2026 19:20:53 +0000
Organization: Usenet Network
Message-ID: <179649845377.3148.17926604674199917416@kernel.org>
References: <20261201174021.7211-5-dsahern@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="3103274"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:NA/mUG/cS0k/vj1YUbC2tAba6sc= sha256:RZn+7c/rQ6S867ZQ/NXqt9XTE9YLw4O8vFCERvbgSlI= sha1:Kby6RnMY+uHu6QM8rwELxs3WQ24= sha256:uMdclzOLxCYRQNRfZ+fFzvdG0mpFj7OarRyz9P4eVE4=
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 DB225117E98; Sat,  5 Dec 2026 22:21:14 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.539
X-Spam-Status: No, score=-3.539 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, 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 70pJakKGVRXY; Sat,  5 Dec 2026 22:21:12 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-378102-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 B2552117E92; Sat,  5 Dec 2026 22:21:03 +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 20C9931D1E; Sat,  5 Dec 2026 19:20:56 +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=1796498456; b=AX2SfGZHnJPcFtHgCJh6+AhocyoqcuvDwQVLRuoU187wq1ZycBKQfYAsYCOX+2xtjHad qy6vapLPqgPYZTwOqWyf5kyox/wZk8TxVVUMBfRCzjMRZ692ZeBS3pN9SzO8rwV8QVbdP Cl755QVk/wuyIbzB965Mr/qq1N3x7S+zUlf7YqTWR44E6BeGlssLIfs1bvx7I5bgbyZW8 ae8B99i2hxHM+tESvtOLYhcmOisASGgssWWLYHBizP+RxeRcBB70IbSJYXVyvwz7NRSzh Ep31487/nnM/jEYQaOcR/+HGjEC7w4BomUMROo8TiKwpuqca2Tir8/0dvXH+74M3NGA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796498456; 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=r15Bo7oT0QbSlClvhiYV2Lg3QODSH3MAoDLsFJqfzsY=; b=AZOZX0p4qussIzC/SeePToPuYuTW6HsMEjHzivKgeAPFtvwI5dTbs0uU1fD2Ss5L3tL0 ewLUD6sqcINaAJiEnVhYPcFnuSn6XybhK7/OY7jvW7DN8CRivk6eQrT3k8OG8qWc8DoJY x7L2Z5P30RQx/x55X7ukkBX3MULtpv71yUKsw0rwFsXZ4QgHBvV6U4J+F8uXLi34O6l2Q aUaSm9lZFWCRC8PjcfgJ9M4kx1jm6bvOufb/MGfHYAYp1f8EdXD0cltiVbGB9im171EqE QHqeEoE8p4vl3w/x4qU76wAMeCLst5XHKmnljOnsWHXo5eigX8LU/AF4IkO1Y9i6HPA==
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=Zhv3yZfC; 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 ED32E606A330; Sat,  5 Dec 2026 19:20:55 +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=Zhv3yZfC
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=1796498455; b=jvLIcYw4Gg/ahOB/sZJBVpQBMwtZnGFi45kD281wrxvWzfSUIF1KDYDXM0sUsZhjBymj 37qzdviXBOT87os2hL4QmSftLYzcaB3opl/2Ro6ssjlXo4wxMPE0+e783c8U3uz6yq+Fm 6nELmlhw25orDB8AHd+m0yoVvMC7aRFbVHXOa40+Z5tRNYYOw8QqUhx3lH32U0lZ3ce/A tna8bfbx5EKyCrTT7mAjQJAZG3W98pzauTSrZqLMUxwOjJTwkamVSw9T8u2W7VMPXirkl QaunwKssARIIi7gFCrMOBzbpMCtKzkj5ifSA6UETFrYoi9pz31/+NFgfntbGOqjoBVw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796498455; 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=r15Bo7oT0QbSlClvhiYV2Lg3QODSH3MAoDLsFJqfzsY=; b=THiTzkSglnws3JkZCFEAfepix9gPAxt9N86B8EjSIXYLBCPpV3zUj90+o/IZybcvo9Ja VarTSuB3UnZKZ3ZM2+kv5FouC+rwUxgNFQbGFhKDdrxtmCvzQvZcVnTAarosyDzh7SD6v JB69QCtJ0wnohDivqGMMOkWNdIROVdZJk87QOygCz4RfPMSYPs7XS2AvHUS9eiqOVKp/K DcLFK6lLj1I7przxfvKxfmbEme1gXV2+e6SRkEZvUFwvPHX/cTz2/r/lsB5+ZY80WciVZ wcwmMv6JMNoME47h5Qbo9U1f2mJHTqrwLN54zKR/eHhK0kMltDwIH9apj08eu5z+1yg==
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=Zhv3yZfC; 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 1B4D0606A335 for <netdev@vger.kernel.org>; Sat,  5 Dec 2026 19:20:55 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4375A1F00A10; Sat,  5 Dec 2026 19:20:54 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796498455; bh=r15Bo7oT0QbSlClvhiYV2Lg3QODSH3MAoDLsFJqfzsY=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Zhv3yZfC/TDqkxvDwaO+j/8Fjp/MYdM6K4s2b79Zi7ehj2sKhQ3C+TdlXd9ZuoEqm a1dQlVmL8AZxZ3jAKxPgFcXYIDJ/k2Y/Lhcda50KQlbYG7Jvaju4WcQAeGHNWmLrjq R4sMIOwicQUJjQe8Azn5ru0xYtyoB1gbOBO+ojx+QLT7oEOaH4KGrUdFXE2VfmNiZ+ zex2JAKTyyVpzQmXdImysqij/Fb1i4SSKY2Rm2fudIu4FlRflWJ1edQQ+xyvKzYigc QVNHK6kWqwfr+4J/2Jf4cQzsr81yaEkv8ip2CQ9dx+iMUmT4FpQrgYAINgYR97c8y0 XSD5yQW4TWoGw==
X-Cc: netdev@vger.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, dahern@nvidia.com, noreply@anthropic.com
X-In-Reply-To: <20261201174021.7211-5-dsahern@kernel.org>
X-sashiko-severity: Medium
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: 13296