🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21317

[RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup

#21317
From: David Ahern
Date: Mon, 23 Nov 2026 21:26
84 lines
11318 bytes
From: David Ahern <dahern@nvidia.com>

IPv6 dsts are validated in ip6_dst_check() against a cookie that the holder
(socket, dst_cache, xfrm bundle, ...) samples from rt->from's fib6_node
(fn_sernum) when it stores the dst. That is later than the lookup that
produced the dst, which allows this sequence:

  CPU0                                  CPU1
  ----                                  ----
  lookup returns Dold
                                        add a more-specific route (e.g. a
                                        blackhole /128), bump fn_sernum
  rt6_get_cookie(Dold) reads the new
  fn_sernum
  publish (Dold, new cookie)

The next dst_check() compares the cookie with the same node's current
fn_sernum and accepts Dold, which keeps bypassing the more-specific route
indefinitely. The same late sampling exists in every persistent cache
(socket TX/RX, xfrm, dst_cache users, SCTP, flowtable, IPVS, RXE), so
fixing each user would leave future users exposed. This is the problem
described in the thread where ovpn hit it.

This series moves the validity into the dst, as IPv4 does with rt_genid:

 1. every dst carries the netns route generation it was built under and
    ip6_dst_check() compares it with the current one; holders no longer
    contribute a token.
 2-5. keep invalidation targeted where it was before: ip6_link_failure()
    clears the failing dst's sernum, nexthop group changes bump the
    generation, and PMTU/redirect exceptions invalidate only the pcpu
    dsts of the affected nexthop, as IPv4 does for fnhe.
 6. rt_genid_bump_ipv6() becomes a counter increment like its IPv4
    counterpart instead of walking every tree to rewrite fn_sernum.
 7. the generation is sampled before the FIB is read and carried in
    struct fib6_result, so a dst and the FIB lookup that produced it
    refer to the same point in time. Without this a change landing between
    the lookup and the allocation is folded into the stamp.

Long-lived dsts are never re-stamped: pcpu and exception dsts are shared
by all holders, so re-stamping one would make it valid again for every
socket and dst_cache that already saw it as stale. A stale pcpu dst is
dropped and rebuilt; a stale exception is treated as a miss. This is the
same behaviour as IPv4, where a stale cached route fails rt_cache_valid()
and a new one is allocated.

Known trade-off: any FIB change in a netns now invalidates every cached
IPv6 dst in it, not just those under the affected node; stale dsts are
rebuilt lazily on their next use.

Changes since v1:
 - Do not re-stamp pcpu and exception dsts when a lookup finds them again
   (patch 1); that made stale dsts valid again for other holders.
 - New patch 7: sample the generation before the FIB lookup.
 - Updated the patch 1 commit message to match.

AI assistance: Claude (Sonnet 5.5) helped develop these patches. I have
reviewed them and take responsibility for them.

Ralf: Patch 7 is alternative to your patch that adds the cookie to the
APIs. Instead the result struct contains the genid before the lookup is
done. Adding it to the fib6_result seems simpler and accomplishes the
end goal everywhere.

David Ahern (7):
  ipv6: validate dsts against the netns route generation
  ipv6: invalidate the failing dst in ip6_link_failure()
  nexthop: factor out nh_has_f6i()
  nexthop: bump the IPv6 route generation on group changes
  ipv6: scope exception invalidation to the affected nexthop
  ipv6: make rt_genid_bump_ipv6() a plain counter increment
  ipv6: stamp dsts with the generation sampled before the FIB lookup

 include/net/ip6_fib.h       |  50 +++++------------
 include/net/net_namespace.h |  36 ++++++++++---
 net/ipv4/nexthop.c          |  42 ++++++++++++---
 net/ipv6/addrconf_core.c    |   7 ---
 net/ipv6/ip6_fib.c          |  76 +++++++++++---------------
 net/ipv6/route.c            | 105 ++++++++++++++++++++++++------------
 6 files changed, 178 insertions(+), 138 deletions(-)

-- 
2.43.0
Technical Details
Message-ID: <20261123212623.106153-1-dsahern@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369777-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369777-linux-kernel-netdev=dewy.ru
From: dsahern@kernel.org (David Ahern)
Newsgroups: linux.kernel.netdev
Subject: [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup
Date: Mon, 23 Nov 2026 14:26:02 -0700
Organization: Usenet Network
Message-ID: <20261123212623.106153-1-dsahern@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3988407"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:AdK1txkmhM44cuEOMvW+NHxmQGc= sha256:LbOan9wmQTbmEPPWQzgC0AYrZ403h7PSYfDreHh0Zks=
	sha1:BaYH2vJdpr5hWi5CVRhvExPeDj0= sha256:LAKP/I2jKk3/Fnsp6UqkpTXuh6sNC347RPWWtRWhxq4=
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 F3294125DC7; Tue, 24 Nov 2026 00:26:44 +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 Q8hfVWh5zFNK;
	Tue, 24 Nov 2026 00:26:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369777-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 6E4BB125DB9; Tue, 24 Nov 2026 00:26:32 +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 7255B301F7; Mon, 23 Nov 2026 21:26:30 +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=1795469190;
	b=HGOIB+degXNAmRdXMaTiGcj3j/Hx4O0HYEv2rb4UMvfYXQj0138l+iDZXSXYk8S8vtHU
	 J7HAyjBxbinflA6nVfxuAn0fARY+AT9KAbBxrdEgk3kPZ6fDyf0pjsL9EPQOSIlrrOnFm
	 AfQiZAYldU2gQV8MqtJTfWplf/5/k4fcBDlxtIV5R5laUWWuf9YOiysWv6fFC2k+95Roq
	 Zq9PH441yu3UOEQ5QD5shazyYStUv82SPdq0S/YitxBnrGcQluympNA93z7zXvR/JCdMW
	 ciblBHTxT9FcGHkAjqLtcfosg9hGkgdWSKwucVreRJODgh8qkg7vdvKlcKED75X0d4g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795469190;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=QZuyscIJTtdqnDMZMnvVqc44iOBtq5csY34+KaIhoYQ=;
	b=csjQvhqMesydv3OtjSMxtiqL3JqVn2fkId+yHBYFYkBbcCPX2i5HSJceG5ELW0AldJxu
	 K41XWoIhU93twXJEpYcc8Xt+4aDJYWnCwJZcdftCjIhcxvIFm6IQoVc5mIXN4Kr2kgjgL
	 4TKuorF8yfMgJGzkpjhb3q5NPG78mQi7TI50TMN/6iF/F2X1nP8qVbp6ezez5cCEmP5Rz
	 otB6vmRbrzY+Q0fmVVL86m+4BLMno3EbLwxtpSCa+UyCHVgnoUz3rS5d5qceiyS0kwpxJ
	 2CzQpHL3GOEkn5SSHRiEyIm4hnIIWCP3OUzuyWywfavncW9A6T7ViJjaFcaanwzE/pA==
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="Mo5cDU/T";
	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 493CA606A32E;
	Mon, 23 Nov 2026 21:26:30 +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=Mo5cDU/T
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=1795469189;
	b=G7uo+RFNWNtOal3W9ZUymTtb9srqFGVAnZ0+qKb0M69ipBm9tA/wAxAdj7fV0xOv5/p8
	 fVXu3Fz9x990y6H2utB6KitzPbFVhVovAPISH+fu1eaN3zZh5BjyrVQt9FojoXUy6IOTM
	 sZUv3JY8v5XJRH78CjhKEpp5cUk7Kh29oXrdvcVKF/QJZzanmJ5/hrrS89ZyvekFZ+HqQ
	 mFeTKWHyGeyTFbXpgmUmsWZzHK/iLArcly4mlvgXzFMDI7JOw69+jbYxMJ7aI/L59j9r6
	 eHB6bDttu+K7njM8lYGEZNcAb6krL5PTTC1pSZxIGxhIwmAJLtyAumVGanC4LCf3z8g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795469189;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 MIME-Version:Content-Transfer-Encoding;
	bh=QZuyscIJTtdqnDMZMnvVqc44iOBtq5csY34+KaIhoYQ=;
	b=NUFI9F9U89WPsrj7UeBzYvpaQfgle4X68dw/bughAf2XnWwe/qqcOLd404CbmAqov53a
	 LRdGgRzCVWYdxj8YbAtmmGlLh+Y0k3qrUyTpzasePNL4hXsNT+yuCvMLK//K5WQ5VUM8y
	 xZIUB6+Jwq8AMT0G9vaKVedY3Nd9ukQJo/aDOcrXiPHN+A/iE3HrqF2ZckoUdpoTFmzrT
	 tkkQhiyseAq2WhoQmK+L9NX6VnGKjl0lu4X/G6P1Dscxy6XjkAyfGvn31BUEihP16u7IC
	 PBC6INqA+UQhkpd8aXUW3E7AUNXO5H6rBDXdNAnaIebp5NRPWrbPnVOjeC9VWBbaQqQ==
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="Mo5cDU/T";
	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 66A35606A31E
	for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 21:26:29 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B05501F000D1;
	Mon, 23 Nov 2026 21:26:28 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795469188;
	bh=QZuyscIJTtdqnDMZMnvVqc44iOBtq5csY34+KaIhoYQ=;
	h=From:To:Cc:Subject:Date;
	b=Mo5cDU/T80Z2rbSHKqsoNs/Kn1Hjw2PtF4mCzBoNsgxWBXNfAA04qvEwhRXgbVet1
	 X9EeYX8CFpOLhbV8QkwnmTs0xzjgOtDdtxNzFj/u7bICL3RH6i0n1rqY0OTJ949zyV
	 KJYd+qrMzRCszQpfn/NUUs+p8a4D5t2tbcxiHDsDmZ0I0GN1ovn0c36FzfFHeeqeQ3
	 RGEtx0jUo44el3sQsjv5ZNPLXqDLFcq91C9uBdbxJS7KLOEGjjuDnsKmDNqJ7anQ1t
	 h9eAYxrdmWQtkNiaePUv7FRxIPP0ewinWqqPMsY3WkM2vjUPtWJC/GUv2hmzrPKRuV
	 Sk9Tvdv8b6n7g==
X-Cc: ralf@mandelbit.com,
	David Ahern <dahern@nvidia.com>
X-Mailer: git-send-email 2.43.0
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