Article View: linux.kernel.netdev
Article #12059Re: [PATCH net v2 2/3] ipv6: ioam6: use transformed packet nexthdr for ECMP re-lookup
From: Hangbin Liu
Date: Fri, 06 Nov 2026 07:38
Date: Fri, 06 Nov 2026 07:38
167 lines
15209 bytes
15209 bytes
On Thu, Nov 05, 2026 at 12:22:34PM +0000, netdev-bot+sashiko@kernel.org wrote:
> 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.
Thanks for the report. This part touch all the policies. I need to think
if I should drop this patch until there is a better fix.
pw-bot: cr
Technical Details
Message-ID:
<au2D5hjp0U1ilXEI@fedora>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357814-linux-kernel-netdev=dewy.ruReferences:
<20261103-ipv6_ioam_ecmp-v2-2-6ef0318bdb5e@kylinos.cn> <179388135485.488856.15442544337186327982@kernel.org>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-357814-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 2/3] ipv6: ioam6: use transformed packet nexthdr for ECMP re-lookup Date: Fri, 6 Nov 2026 15:38:14 +0800 Organization: Usenet Network Message-ID: <au2D5hjp0U1ilXEI@fedora> References: <20261103-ipv6_ioam_ecmp-v2-2-6ef0318bdb5e@kylinos.cn> <179388135485.488856.15442544337186327982@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3820911"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Ud9VOC8Ui8qiHm0vmBjgSd0LHEk= sha256:GNBbf9IjIPYz5l8s8FOBHqCRq0GsKhX/TmImLeOQRiE= sha1:81q+ecj7nJ4X8oVG4DqPCZqGUC0= sha256:CUBRn2F3xPaq0a66OPDUUJ1rX3KEya0cVaYy/iusun4= Content-Disposition: inline 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 5980F1131A5; Fri, 6 Nov 2026 10:42:28 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 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] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev 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 0rXiZXciUZNE; Fri, 6 Nov 2026 10:42:22 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-357814-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 479A81131A0; Fri, 6 Nov 2026 10:42:14 +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 4C63425EBE; Fri, 6 Nov 2026 07:38:29 +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=1793950708; b=A2qogQAhBw0x+eTcMukEmLlIy0ErPU0Jp384/6VGOnPBpFpmtbiifsyOeNwI4NFi7Jv6 7YpFdD+JkpSLb4S04R2XbClpyGVyZD9MVzvJ9tC6tt9DYKbTY8fmTAT/2cVe9aOXAPoJh u8wLDLswolxv+ue31eiKyJHIxlWdnNKkMCT+exrzevC349E1sCrU1SGMdoUPeepPE2lDK hRh0tgR4MYz+alc5UScjeXXTdCAcs+9XVYJANmCVCICg+9QIUQ0HQyVP9Ipf0NQG/5VuH Au4uLJqA9AsoHXYcVNVROe1FGOFeWwbO9W5ewPn2f0Fl1FZysagQ1vg5yJ7wFI8Lg0g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793950708; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=yqj2X60t6GkEB0Hd3slamrcdw7uuMt8wIZvLf0iaHgw=; b=Ikmz3Yi78H/0mk+bNLoc+xX17jyy2qPpiPWuk/RrR6CFwQDYa052SfibzwsfcZpzWprB k/xeCh2cLuA/B7ks4f1QTt8J2xg+7M2o6iyc4pl4u9pjN9igmpxOWM4mwp7ybznrFyaKa XRv0ScThGcsutuQfpo+uq268f8pIqogO+I24INLo5ghODSZb9BMw9WMO/o80paO3kPY5g QHMCkMIIJTVzvFmB4QOmqTZi52CD0vvfP2Cjwr/jSIkt6T44QJf+XzF+1PUMs20viQm2v fgA79YLxH3rpnXK62evHEYyWD97MP6F9BSW9xYz6nvwRLMLk54xzeEXkDeXi6Qj8SWg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=tH0ObvQ3; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; 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 94B74606D810; Fri, 6 Nov 2026 07:38:28 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=tH0ObvQ3 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.124 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793950707; b=jvl2paODaqOv8SlduJbGbR03bbMKLFrhKnU17SHAYws9usTxZJcpEgBtC9To3+RdVboT gAfRU8DQIcKiY9f7WLwzjfPFMpKQIl2TZ/jhLcgw2AFsh++dbRPrlOFJrCBFkBBhym89H zoNAxB49or6dpClei3hwC2dunmXVI9/mr6vX4GrEmieOeq0FFZ4aSdzc5iBhJuAJ6uSFP qiM2MPTJCDBzeh0ii+dx1tqQQtjGfs88VFpbQ7qOrmUT6sE2yACPft0fsGstJPTKrnJk/ vz2YJsRqWL1Yj0VjCIjzMi2cWOOjSMI4nWmETRVBsqSNFNksGcsxIfwO/6pjbHWlozQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793950707; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=yqj2X60t6GkEB0Hd3slamrcdw7uuMt8wIZvLf0iaHgw=; b=zPtmQV/wJCdQ2Cxox/tQGWSRC+CfeePY7MF9rhhsXV8ik9yJJ8S2rBoS/L1lrutqN0AX cvVEMoRoHVxVWfc34QLAm9pQDQZxiRger0msmCB5IFwZfX+9S9DBY8zYccnAQK8Qkfohl NP9pqc+/Cf7vapHFFI4+L1kajkCFR6N7K8MLnl5rmRw3qJ/GV/8eG5NapIUXRj6tmz0i1 bvlcyxFy1CMfXAH7WUvQiFhb2ICsVH7K7qAA8hfgyO829WKSf0deY3DyXGdqY0T0OkPQD 5G71w1f2DhAkLjKucLptClrMYClc/HHWyH++QDPslsjr8L/N93mhjQygMeWGbucaDlw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=tH0ObvQ3; arc=none smtp.remote-ip=95.215.58.124 X-Received: from mta1.migadu.com (out-124.mta1.migadu.com [95.215.58.124]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04EE8606A335 for <netdev@vger.kernel.org>; Fri, 6 Nov 2026 07:38:26 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 04EE8606A335 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=vxGWNLncSlcQs4swV+6nfyQ5Qh5FfXbxSfHWmDFVw98=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793950705; v=1; x=1794555505; b=tH0ObvQ3DbFZNgYhD58A1r3joh7DYzbyq4OiGkSuCFTqclMOsVruo3MDEVMb/Zo26y+DDasD LtuQLIAhVuby9stJeel9e+Q8keyCsV2cULbgZ+u2eH6trynM1duQEfE0ICZs7OoFyrZ1JngDrtA OmoEorLIQV2H9Gy/q8A/vQeA= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta10.migadu.com with ESMTPS id 288db3607269e5ae; Fri, 06 Nov 2026 07:38:24 +0000 X-Mizu-Trace-ID: 288db3607269e5ae X-Migadu-Flow: FLOW_OUT 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-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-In-Reply-To: <179388135485.488856.15442544337186327982@kernel.org>