🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19913

Re: [PATCH net-next v4 2/4] ipv6: take fib6_sernum from a sequence shared by all netns

#19913
From: Ralf Lici
Date: Fri, 20 Nov 2026 17:52
61 lines
11725 bytes
Hi Qiliang,

I stumbled upon this series while looking for what caused a conflict
patchwork reported on one of my series [1], which touches the same code.

On Tue, 17 Nov 2026 21:28:31 -0500, Qiliang Yuan wrote:
> 2^31 bumps. fib6_new_sernum() callers only hold their own table's
> tb6_lock, so two tables of one netns can store their values in either
> order, and fib6_sernum is no longer monotonic per netns. It is only
> compared for equality, so this costs at most an extra invalidation.

Eric raised this on v1 [2], and for the equality checks I agree: values
are not reused, so a stale value cannot match. What the atomic_set
changes is the ordering. It comes after the full barrier of the cmpxchg,
so nothing orders it before the node stamp in fib6_update_sernum: a
reader can sample the new fn_sernum while still reading the old
generation (this one is allowed on arm64). Nothing in the tree compares
the two today, but my series relies on that order, since it brackets the
lookup and cookie sampling with two reads of the generation.

The late store also loses the guarantee that a reader seeing a value
sees the routing changes published before it. With the per-netns
cmpxchg, each update reads from the previous one. Here, CPU0 can draw 2
and stall while CPU1 links a route, draws 3 and publishes it, and then
CPU0 stores 2. LKMM allows a reader that reads 2 to miss CPU1's route
(x86 and arm64 forbid it in practice), and a per-cpu dst of a nexthop
object allocated from that lookup records 2 and passes rt6_is_valid
until the next bump.

Drawing from the shared sequence but publishing with a cmpxchg on the
per-netns counter keeps both, at the cost of a wasted draw on
contention:

static int fib6_new_sernum(struct net *net)
{
	int old = atomic_read(&net->ipv6.fib6_sernum);
	int new;

	do {
		new = fib6_sernum_draw();
	} while (!atomic_try_cmpxchg(&net->ipv6.fib6_sernum, &old, new));

	return new;
}

where fib6_sernum_draw is your current loop on fib6_sernum_seq. I
checked both cases with LKMM litmus tests: they are reachable with
atomic_set and forbidden with the cmpxchg publish.

1/4 has the same pattern for rt_genid, and IPv4 bumps can run
concurrently too, since xfrm policy insertion does not hold RTNL.

[1] https://lore.kernel.org/netdev/cover.1795166508.git.ralf@mandelbit.com/
[2] https://lore.kernel.org/netdev/CAL4WiioL+wiv3jgqeT1qiZ2mGWQ+HV+mEQP2K0aFMCpjDvwYDg@mail.gmail.com/

-- 
Ralf Lici
Mandelbit Srl
Technical Details
Message-ID: <20261120175241.289834-1-ralf@mandelbit.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368067-linux-kernel-netdev=dewy.ru
References: <20261117-bug-net-netns-move-rcu-barrier-v4-0-43e1ca0aac7f@linux.dev> <20261117-bug-net-netns-move-rcu-barrier-v4-2-43e1ca0aac7f@linux.dev>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368067-linux-kernel-netdev=dewy.ru
From: ralf@mandelbit.com (Ralf Lici)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 2/4] ipv6: take fib6_sernum from a sequence shared by all netns
Date: Fri, 20 Nov 2026 18:52:41 +0100
Organization: Usenet Network
Message-ID: <20261120175241.289834-1-ralf@mandelbit.com>
References: <20261117-bug-net-netns-move-rcu-barrier-v4-0-43e1ca0aac7f@linux.dev> <20261117-bug-net-netns-move-rcu-barrier-v4-2-43e1ca0aac7f@linux.dev>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="3226138"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:AvYbgOgtxVUcuz6VB5TS7VAHeKE= sha256:ywENdY6euS8qMYGGX4UCN2xNCmnK1Bntsk+0XSECEv8=
	sha1:dW9KLCZ1gW9Kn11bvoF2/lgZ/cs= sha256:Igz4510TD5BQUwkiewQfcLVT3EjTUHRVLCaV5jjusBs=
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 16802115A35; Fri, 20 Nov 2026 20:53:28 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	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=mandelbit.com
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 Tg2psM5JJJdd;
	Fri, 20 Nov 2026 20:53:23 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368067-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mandelbit.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id E9D481159D7; Fri, 20 Nov 2026 20:53:12 +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 3D801161CB3; Fri, 20 Nov 2026 17:53:07 +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=1795197180;
	b=uplY9dJ79zLrcSQ9Knmvtl4MVkLQiatAPA8lPfBVBmzEBAaev70DsfRdmZZIPhPl8v9u
	 Lms2mHuXW4yimkXOu4O9a/Rs1dbyf7YnGh4+cLOP6g8e7KZAAF8WYsG8iXX+FsilWFGvo
	 tE3WK2jLS24WmZn5YVFpkEDLss/cF3AJUXCMNVmLl0xQgJWtCup5eAtRSQNMceXkwg04M
	 Nw7LVkQPf4c+ab0noRirsln9THKYyABEIwI3D1Ht4m6I+Owoe8LnccEDJmSYUcyOBW0fk
	 6BNjCPJJIUP2ACAL5MFZQDfhdzSfqiiVi4FuYN/kZbIcRUCLl4jNJxN0wJf3OHYtERg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795197180;
	h=X-Original-To:Received:DMARC-Filter: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-Transfer-Encoding:X-Rspamd-Queue-Id;
	bh=lS4PH3pwJigP6vQkCo1ANPeGs5eVG6653IQY7i2B+EU=;
	b=bwSz/0P/F5qkQZ8+vpJGVMn5zrUi0eMLFR78n4/hRAeILnCT3vwcfr2n+ercYke3kQDh
	 ShwJA/DLWRZ6Kjs3gSUvSjMLl9Ch02646J8/JuxGZsdw6e9b13ExXLwjGuWoGK+PLUOyu
	 QChz8R1RhNsyhWULcDo62CmUxW1LREyPed7Youzdonv7KScZIoH4/OyfE7+6ub7qnTX78
	 QHVDH4biGcFNiUlLQ9rwW9pHOcTeV5H5Lod3KLxUDKAGaMfQHFXa33pvt+XZ/BtkgkYFP
	 KQ5hit0hTi2U1wxlNiLwb9kGfg6wchXNPT3vxMgo00XYweOGz9PIxXPW6pxCTizLQgg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=X1ZwIyo7;
	dmarc=none header.from=mandelbit.com;
	spf=pass smtp.mailfrom=mandelbit.com;
	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 09303606A339;
	Fri, 20 Nov 2026 17:53:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=X1ZwIyo7
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.46
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795197174;
	b=oEyASlJKoaZGaX9pbXDPJOT3jD31zIfccN7ry287jLtd4YWx1KAcmDX8xb47Qn6lG7Rd
	 1bHUbmtsGeI3lzzUZloA5b/ZpTxIKHg/fJCBTj7B0aw+ZrP4K5DxEBlsM+GxzGu8T4gdb
	 vAxlizIeWC+h3GQEmsQdUVLtUmbHGhoA145xhHe25UFh8ZhPYdWOgjqOmPJnj7LiSDEJy
	 dhFDxNFYncR6xDFvbe5ABS2XfRXlXJ10G2S1rUha7SV4CnpsyYnD3kMdO1bKGpBRjE3QF
	 m/X+5Kk6H+tZc4wR61ND61XA2LMILxiqZ5NvXnP8DP4Jdz65Y7fFZswFU0QZdMQvGyA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795197174;
	h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:X-Rspamd-Queue-Id;
	bh=lS4PH3pwJigP6vQkCo1ANPeGs5eVG6653IQY7i2B+EU=;
	b=TDcnfFK7paopEFCFfiAVmwuXHqnsaMEBbRUSBwiLmOrkGvt3azca0CW/xMzYAcWR5/5U
	 v2ViSOBLWZAdFK9jwD8wqy8pdKXIT2wxrESIY71xJETxZ8iPMECSEvx2q9wvK1RbIHMUB
	 gDnyNWhdKwIIC6WSL6vaNubbMTCOp3hWplqBBzPj5mNDXeFDtmfJNDt7RR1G7gn94EI87
	 weQ3LZN22qQIJXPJ+Z5ZCx9lqV7yB8PIJCwYgXEckc4YhS1frQFcVeAvbIsBajaggOjwk
	 6vQzJQX77+TR1wOMmls525M2mu3xLyHXI1SyLPSUB7RaSwgWNUfbzuclaDU335XV5OA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=mandelbit.com;
	spf=pass smtp.mailfrom=mandelbit.com;
	dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=X1ZwIyo7;
	arc=none smtp.remote-ip=195.10.208.46
X-Received: from mout-b-106.mailbox.org (mout-b-106.mailbox.org [195.10.208.46])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9038E606A320;
	Fri, 20 Nov 2026 17:52:52 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9038E606A320
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com
X-Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by mout-b-106.mailbox.org (Postfix) with ESMTPS id 4jWNGS6gMfzNkP3;
	Fri, 20 Nov 2026 18:52:48 +0100 (CET)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com;
	s=MBO0001; t=1795197169;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:cc:mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=lS4PH3pwJigP6vQkCo1ANPeGs5eVG6653IQY7i2B+EU=;
	b=X1ZwIyo7TbdvlBKh4Aw8Cd9ZbMZOjfoajtescUoc8lhq25AcqmP8tUQOQxBhP5PT/hgWEJ
	DJsQoBD1F7MVRyk7ABf1Je9B/GfWKJAeOq/+qvpUftZKLEyG7CMPzyg0ZZD17X52oMz5mN
	Ud17JICwoZrUcFna+zp+4e4hQL0fF4TGkjV2TNSXsbFNWx/KWhp9NeK7XI5s7+tIl0MC24
	3dbcJzpQUTJe3S/3J/NCLI2ahza2YiCaHj+o8LuZUNswsFzuKSlaevkxiFdpfEmyLX0/4X
	1Eb2lhHtfRb3Z7fLdDHOTOAW+FJ1DIDOdiW87hMKZOgAzhJxSZH8rR09UOkjJg==
X-Authentication-Results: outgoing_mbo_mout;
	dkim=none;
	spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::202 as permitted sender) smtp.mailfrom=ralf@mandelbit.com
X-Cc: davem@davemloft.net,
	dsahern@kernel.org,
	edumazet@kernel.org,
	horms@kernel.org,
	idosch@nvidia.com,
	kuba@kernel.org,
	kuniyu@google.com,
	linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org,
	pabeni@redhat.com,
	razor@blackwall.org
X-Mailer: git-send-email 2.56.0
X-In-Reply-To: <20261117-bug-net-netns-move-rcu-barrier-v4-2-43e1ca0aac7f@linux.dev>
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-Rspamd-Queue-Id: 4jWNGS6gMfzNkP3