🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #11673

Re: [PATCH net v2 2/3] ipv6: ioam6: use transformed packet nexthdr for ECMP re-lookup

#11673
From: netdev-bot+sashiko
Date: Thu, 05 Nov 2026 12:22
206 lines
15553 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 2 · Medium: 1 · Low: 0

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] The encap cache-miss path in ioam6_output()
  (net/ipv6/ioam6_iptunnel.c:439) now sets `fl6.mp_hash =…
- [High] In IOAM6_IPTUNNEL_MODE_AUTO, local packets (inline, !skb->dev)
  and forwarded packets (encap, skb->dev set) share one per-CPU…
- [Medium] The new call `rt6_multipath_hash(net, &fl6, skb, NULL)` in
  ioam6_output() (net/ipv6/ioam6_iptunnel.c:439) passes an output-path…

--

ipv6: ioam6: use transformed packet nexthdr for ECMP re-lookup

This commit changes the dst_cache miss path in ioam6_output(). For inline
insertion it now reuses orig_dst and caches the fake null_rt. For
encapsulation it re-looks up the route with flowi6_proto taken from the
HBH next header and with fl6.mp_hash precomputed from the skb, so that
the ECMP hash matches the identical packet without IOAM (RFC 9486 C2).

> diff --git a/net/ipv6/ioam6_iptunnel.c b/net/ipv6/ioam6_iptunnel.c
> index cfb2c41634a0b..246533276be82 100644
> --- a/net/ipv6/ioam6_iptunnel.c
> +++ b/net/ipv6/ioam6_iptunnel.c
> @@ -405,34 +405,61 @@ static int ioam6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
>  
>  	if (unlikely(!dst)) {
>  		struct ipv6hdr *hdr = ipv6_hdr(skb);
> -		struct flowi6 fl6;

[ ... ]

> +		if (ilwt->mode == IOAM6_IPTUNNEL_MODE_INLINE ||
> +		    (ilwt->mode == IOAM6_IPTUNNEL_MODE_AUTO && !skb->dev)) {
> +			dst = orig_dst;
> +			dst_hold(dst);
> +
> +			local_bh_disable();
> +			dst_cache_set_ip6(&ilwt->cache, &ilwt->null_rt.dst,
> +					  &hdr->saddr);
> +			local_bh_enable();

[Severity: High]
In AUTO mode, can local and forwarded packets end up using each other's
cached dst? The miss path is now mode aware. The hit path at the top of
ioam6_output() still reads one per-CPU cache, whatever the mode:

	dst = dst_cache_get(&ilwt->cache);
	...
	if (dst == &ilwt->null_rt.dst) {
		dst_release(dst);

		dst = orig_dst;
		/* keep refcount balance: dst_release() is called at the end */
		dst_hold(dst);
	}

Suppose a local packet misses first, so null_rt is cached. A later
forwarded packet on that CPU then gets dst = orig_dst and is encapsulated
with daddr = tundst. Because dst is non-NULL, it skips the tundst
re-lookup. Because the lwtstates match, it leaves through
orig_dst->lwtstate->orig_output(). That uses the inner destination's
route and nexthop, not the route for tundst.

Now suppose a forwarded packet misses first. The encap branch caches the
tundst route:

	dst_cache_set_ip6(&ilwt->cache, dst, &fl6.saddr);

Later local packets on that CPU hit this entry and are processed inline.
They are then sent through the tundst route instead of orig_dst:

	if (orig_dst->lwtstate != dst->lwtstate) {
		skb_dst_drop(skb);
		skb_dst_set(skb, dst);
		return dst_output(net, sk, skb);
	}

The shared cache existed before this patch. However, the commit message
says inline will "reuse orig_dst and cache the fake null_rt, keeping the
sibling from the original lookup", and that encapsulation "still
re-looks up". In AUTO mode with mixed traffic, neither seems to hold.
null_rt is DST_OBSOLETE_NONE, so the stale entry stays until the cache is
reset.

Does the hit path need to be mode aware too, for example with separate
caches for the inline and encap cases?

> +		} else {
> +			/* Encapsulation may change the destination (tundst);
> +			 * re-lookup with the transformed packet keys so the
> +			 * outer hash matches the identical packet without IOAM.
> +			 */
> +			const struct ipv6_opt_hdr *hhdr;
> +			struct flowi6 fl6;
> +
> +			hhdr = (const struct ipv6_opt_hdr *)skb_transport_header(skb);
> +
> +			memset(&fl6, 0, sizeof(fl6));
> +			fl6.daddr = hdr->daddr;
> +			fl6.saddr = hdr->saddr;
> +			fl6.flowlabel = ip6_flowinfo(hdr);
> +			fl6.flowi6_mark = skb->mark;
> +			fl6.flowi6_proto = hhdr->nexthdr;
> +			fl6.mp_hash = rt6_multipath_hash(net, &fl6, skb, NULL);

[Severity: High]
Does computing mp_hash from the skb break the C2 equivalence that the
comment above claims? When fl6->mp_hash is non-zero, fib6_select_path()
uses it as is, so this skb-based value chooses the sibling.

The comment says the outer hash "matches the identical packet without
IOAM". A plain ip6ip6 tunnel, ip6_tnl_xmit(), routes with
ip6_route_output(net, NULL, fl6) and no skb, so it hashes the outer fl6
keys. With an skb, rt6_multipath_hash() behaves differently for each
policy.

Policy 1 returns the inner flow's hash early. ioam6_do_encap() never
clears that hash:

	if (skb->l4_hash)
		return skb_get_hash_raw(skb) >> 1;

Policy 2 dissects through the ip6ip6 header and hashes the inner
addresses, flowlabel and proto:

	skb_flow_dissect_flow_keys(skb, &keys, 0);

Policy 3 calls rt6_multipath_custom_hash_skb(), which returns
jhash_2words(mhash, mhash_inner, 0). Plain ip6ip6 goes through
rt6_multipath_custom_hash_fl6() instead.

For policy 0 with flowi6_proto = 41, the skb result looks the same as
the fl6-only hash, so the precompute appears to do nothing there.
Without the companion patch "ipv6: route: consider IOAM options in ECMP
hash policy 0", it would hash ip_proto = NEXTHDR_HOP and undo the
flowi6_proto = 41 change. That matters for backports of this
Fixes:-tagged patch.

Setting fl6.flowi6_proto = hhdr->nexthdr on its own, without the
precompute, seems to match plain ip6ip6 under every policy. Would it be
better to drop the mp_hash precompute?

The commit message also says:

    precompute fl6.mp_hash from the packet, since ip6_route_output()
    carries no skb and would otherwise drop ICMPv6 quoted-flow and L4
    keys.

Can the ICMPv6 quoted-flow case happen here? ioam6_do_encap() always sets
tuninfo->eh.nexthdr = NEXTHDR_IPV6, so the header after the HBH is
always 41.

[Severity: Medium]
Can this call run the flow dissector without a netns? Under policy 2,
policy 3, and policy 1 when skb->l4_hash is clear, rt6_multipath_hash()
calls skb_flow_dissect_flow_keys(), which passes net = NULL.
__skb_flow_dissect() then takes the netns only from skb->dev or skb->sk:

	if (skb) {
		if (!net) {
			if (skb->dev)
				net = dev_net_rcu(skb->dev);
			else if (skb->sk)
				net = sock_net(skb->sk);
		}
	}

	DEBUG_NET_WARN_ON_ONCE(!net);

In ENCAP mode, locally generated packets can reach this branch with both
fields NULL. One example is an RST sent for a closed port:

tcp_v6_send_reset(NULL, ...)
  tcp_v6_send_response()
    ip6_xmit(ctl_sk, buff, ...)
      NF_HOOK(..., dst_output)
        lwtunnel_output()
          ioam6_output()
            rt6_multipath_hash(net, &fl6, skb, NULL)

When sk is NULL, buff comes from alloc_skb() with no socket attached.
ip6_xmit() sets skb->dev only on the EMSGSIZE path, after NF_HOOK has
returned.

On CONFIG_DEBUG_NET kernels this warns on the first cache miss on each
CPU. On all kernels, an attached netns BPF flow dissector is skipped for
these packets. Before this patch, ioam6_output() never passed an skb to
the multipath hash.

> +
> +			dst = ip6_route_output(net, NULL, &fl6);

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261103-ipv6_ioam_ecmp-v2-0-6ef0318bdb5e%40kylinos.cn
Technical Details
Message-ID: <179388135485.488856.15442544337186327982@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357310-linux-kernel-netdev=dewy.ru
References: <20261103-ipv6_ioam_ecmp-v2-2-6ef0318bdb5e@kylinos.cn>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357310-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 2/3] ipv6: ioam6: use transformed packet nexthdr
 for ECMP re-lookup
Date: Thu, 05 Nov 2026 12:22:34 +0000
Organization: Usenet Network
Message-ID: <179388135485.488856.15442544337186327982@kernel.org>
References: <20261103-ipv6_ioam_ecmp-v2-2-6ef0318bdb5e@kylinos.cn>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3635197"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Y9x2U1LE7BcnQT2xIi/H3Andb/A= sha256:CoO+9g5wc5elZdxuouUNQpXFseGXV0swHncbrre9Dp0=
	sha1:j8UV/zpGnfkZDKMRQiJ3PRTTAf0= sha256:NYwIpARUfUy2wSBNvNYSFhl/fJMyJkVYUM0RvMpR7+8=
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 10D2F112F72; Thu,  5 Nov 2026 15:29:21 +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 DqsA2cFywDJc;
	Thu,  5 Nov 2026 15:29:17 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-357310-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id CE152112F6F; Thu,  5 Nov 2026 15:29:08 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id B736037031; Thu,  5 Nov 2026 12:23:08 +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=1793881363;
	b=GOEvUOnjOSbgiS4ebf1UDgYa2Y7I5+NIB+Mkouij2Wqor+NUA12UJzI0LZboSNC8ML32
	 AumVgojsuddriC9XW36UOcDKlMAhXRRYWS4HIKnMKJrUKiNesmX0W6sxbuVdZfYdJxG4V
	 4wIUMejIjmpHtWbwATBjKMTGm3X2TLO/UuYvrGE2TsETESkISys2GT3rmIoHBTOZqRk3+
	 CXVdbmLgh/UeQsDAFcKTERaH2kojm9eLpf3ytrFFQuTmkaZJoAfNSjLwrPOlyr4mBvdeq
	 pmIXBvkI8LpAnIgc2eBUzcE1JmBfU76fjiVb0ABYuILL6bHmMlUtd43DQR3Lduv218A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793881363;
	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=51XuEKp7AvViCgMvOr9QbMagrxSSSGv9BFPwFm9pL4U=;
	b=gVfdFAQ0pNW4kSeFRqaMe8JDHIIZmdh1cSpK7wwZjNKMM9HwODVkErufoogKeIFa4ikM
	 Jqz/fkbGEL+yoB5qcC8Fg72Dwz9mwaroKWsoERycLWbezzvwQAfyYA9yuZ/y5+DBJsvGe
	 KBO80l6TCLFGG77hVXsPZqcqCtxAMzBTEZOktyJN6o4pZynjDkyTu2y+7XBlGN/cJ/NEX
	 Rv3Hnkzm5dLUcYjKave6RyzQtiMJ/Y4LflB8MoHbmC5E1aGLn0/2yC31dYMRjZqZ/2FIq
	 KU4Xt5KZL/icBviYEY9iQ9T7qacbIVq5rSFVDbqRvruMoIAyeHnhv8P4lXuaE4Jd5AQ==
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=lQcXh16L;
	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 4D59D606EE81;
	Thu,  5 Nov 2026 12:22:43 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lQcXh16L
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=1793881356;
	b=huyklPqbbFGkaGvJjHAiaPjC3t2ljlgxVzSoa3iqZFejd3MJ7VBuwvM/z6urcDhw2nC2
	 uMyiPuE07NchrPzIIXyLtJoHtdCn1IhXiZBr9IumXVnV9Q5SwRKLkKgfFsWx3EcFVbkjX
	 a9FQUXYQv6c2qDbz4lpeyiLX78oMYgR69PanO4yLuDPL3a3tHbhQu2Uche9myAFG9INes
	 hOr//f/IRAlIb+k6v+IEXQttK5s52QL1eLFAINYgn0FBbqEimiw/wb8nKzC9B8t9+Tdmm
	 ed4nUvZ2zEq+izsRdCfcrGrmJXWeL1nSpRWRiXyZN0GeZN5dF+p9D0A0im5PI0mBXog==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793881356;
	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=51XuEKp7AvViCgMvOr9QbMagrxSSSGv9BFPwFm9pL4U=;
	b=QR6S5GvN+Bwdvqg/9VOkU2EGav4geeNzHFUwiel2XyJrlSuHHl8Oje/kjNXUVUyniKSs
	 /Cm/gcfabaLZGoU4OvJtTO43i/gtBgSe2LbeIjox4XKbrJTPI3TWRBgwQwdI8TeOc6UTl
	 3ZWkbOk8grDBYEiKE4T/0rjVwQKh81z3iS2JpHjsiR3doRpodSZnM4yLsmZ59EzmSiKax
	 Ai/nr8FUtHqHEvPquZty7BeO5xYkg2UW9FnerD7Ew55SjTvkG0Nw2Z/bm1EFt2Tepdhvc
	 TWM6cS49lhyRC9fn54Wr/cvhWjNkhFn8iMq4vBmtxnjJAzcmw/5IOsDle/3Ug2t6CyQ==
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=lQcXh16L;
	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 504F0606A33A;
	Thu,  5 Nov 2026 12:22:36 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52C8A1F0093A;
	Thu,  5 Nov 2026 12:22:35 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793881356;
	bh=51XuEKp7AvViCgMvOr9QbMagrxSSSGv9BFPwFm9pL4U=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=lQcXh16Lpg0844yiIjRtLPM4PEXa9WWGQvf0+lRRHdF/9GXkCv4RXgFGvVYYtpSRl
	 /mHhTjEKdVNupz+11bj1o+CofU6DYK0IcSOOVbDuwSc/jTh5VLKz58R40kXrwc9j62
	 a/fXGwSJm+GZzOLO68tBVJBURMxZyIUC2LeHBD1H6KXmLSWH2J4CMCD2H8b3KmlBds
	 pLdICoTiHpYQEkuCwUbjwJQuk8l5Jxi41jtREFtGrzCRPXBoLss8Mrazu0JmpUUwax
	 XkhZbaRP1cEgddxa2Oi5fBe0iFyxECKQpKzCMgXiSbnTlj0NvVPsQI2GEpXAweK2+I
	 3UQKF9pAYukkA==
X-Cc: dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 justin.iurman@gmail.com, shuah@kernel.org, linux-kernel@vger.kernel.org,
 netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
 liuhangbin@kylinos.cn
X-In-Reply-To: <20261103-ipv6_ioam_ecmp-v2-2-6ef0318bdb5e@kylinos.cn>
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