Article View: linux.kernel.netdev
Article #2176Re: [PATCH net-next 3/5] seg6: apply the PSP flavor together with NEXT-C-SID in SRv6 End
From: Hangbin Liu
Date: Mon, 12 Oct 2026 08:17
Date: Mon, 12 Oct 2026 08:17
134 lines
11575 bytes
11575 bytes
On Sun, Oct 11, 2026 at 09:23:08PM +0200, Andrea Mayer wrote:
> Since commit bdf3c0b9c10b ("seg6: add PSP flavor support for SRv6 End
> behavior"), an SRv6 End route can be set up with both the NEXT-C-SID and
> the PSP flavors, e.g.:
>
> ip -6 route add fcbb:0:100::/48 encap seg6local action End \
> flavors next-csid,psp lblen 32 nflen 16 dev dum0
>
> In RFC 9800, the NEXT-C-SID flavor (NEXT-CSID in the RFC) changes the
> End processing only when the Argument is not zero [1]. With a zero
> Argument (i.e. when the IPv6 DA carries no further C-SID), End is
> processed as in RFC 8986, and the PSP flavor (when set) applies
> unchanged [2]. If the packet arrives with Segments Left 1, PSP must
> then remove the SRH.
>
> However, on a route with both the NEXT-C-SID and PSP flavors,
> input_action_end() always uses the NEXT-C-SID processing. The
> NEXT-C-SID processing handles a packet with a zero Argument as End
> without flavors, ignoring PSP. Therefore, if this packet arrives with
> Segments Left 1, the SRH is not removed.
>
> Fix this by using the NEXT-C-SID processing only when the Argument is
> not zero or the route has no RFC 8986 flavor. Otherwise, the packet is
> processed as End with its RFC 8986 flavors, in end_flv8986_core(). With
> a zero Argument and Segments Left 1, PSP now removes the SRH before the
> packet is forwarded. If seg6_pop_srh() cannot remove the SRH, the packet
> is dropped, as on a route with the PSP flavor alone.
>
> Found by manual code inspection and reproduced in a VM without kernel
> changes or error injection. A following commit adds tests for this case
> to srv6_end_flavors_test.sh. The tests reproduce the issue: they fail
> without this change and pass with it.
>
> [1] - https://datatracker.ietf.org/doc/html/rfc9800#section-4.1.1
> [2] - https://datatracker.ietf.org/doc/html/rfc9800#section-4.1.7
>
> Fixes: bdf3c0b9c10b ("seg6: add PSP flavor support for SRv6 End behavior")
> Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
> ---
> net/ipv6/seg6_local.c | 50 ++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 47 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
> index 26cd4facbe36..427d12fedfc3 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -551,6 +551,47 @@ static bool seg6_next_csid_enabled(__u32 fops)
> return fops & SEG6_F_LOCAL_FLV_NEXT_CSID;
> }
>
> +static bool seg6_flv8986_enabled(__u32 fops)
> +{
> + return fops & SEG6_LOCAL_FLV8986_SUPP_OPS;
> +}
> +
> +/* check whether the NEXT-C-SID processing has to be used for the packet,
> + * instead of the RFC8986 flavors set for the given SRv6 End* behavior
> + * instance.
> + *
> + * This function returns:
> + * - true, when the packet has to go through the NEXT-C-SID processing;
> + * - false, when NEXT-C-SID is not configured or the packet has to be
> + * processed on the basis of the RFC8986 flavors.
> + */
> +static bool seg6_use_next_csid(struct sk_buff *skb,
> + const struct seg6_flavors_info *finfo)
> +{
> + const struct in6_addr *addr;
> + __u32 fops = finfo->flv_ops;
> +
> + if (!seg6_next_csid_enabled(fops))
> + return false;
> +
> + addr = &ipv6_hdr(skb)->daddr;
> +
> + /* NEXT-C-SID and the RFC8986 flavors combine according to the
> + * DA.Argument (see RFC9800, sections 4.1.1 and 4.1.7):
> + *
> + * DA.Argument RFC8986 flavors processing
> + * (1) != 0 any NEXT-C-SID only, SL unchanged
> + * (2) == 0 none the behavior, e.g. End
> + * (3) == 0 one or more the behavior with its flavors,
> + * e.g. End with PSP
> + *
> + * In (2), the packet still goes through the NEXT-C-SID processing,
> + * which runs the behavior (e.g. End) when the DA.Argument is zero.
> + */
> + return !seg6_flv8986_enabled(fops) ||
> + !seg6_next_csid_is_arg_zero(addr, finfo);
nit: based on the comment, maybe we can change the order to
return !seg6_next_csid_is_arg_zero(addr, finfo) ||
!seg6_flv8986_enabled(fops);
No need to change if there is no new version patch.
> +}
> +
> /* Processing of SRv6 End, End.X, and End.T behaviors can be extended through
> * the flavors framework. These behaviors must report the subset of (flavor)
> * operations they currently implement. In this way, if a user specifies a
> @@ -865,7 +906,10 @@ static int end_flv8986_core(struct sk_buff *skb, struct seg6_local_lwt *slwt)
> if (srh && !seg6_hmac_validate_skb(skb, srh))
> goto drop;
> #endif
> - flvmask = finfo->flv_ops;
> + /* NEXT-C-SID, when configured, has already been evaluated by the
> + * caller. Only the RFC8986 flavors are left here.
> + */
> + flvmask = finfo->flv_ops & ~SEG6_F_LOCAL_FLV_NEXT_CSID;
> if (unlikely(flvmask & ~SEG6_LOCAL_FLV8986_SUPP_OPS)) {
> pr_warn_once("seg6local: invalid RFC8986 flavors\n");
> goto drop;
> @@ -919,8 +963,8 @@ static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt)
> if (!fops)
> return input_action_end_core(skb, slwt);
>
> - /* check for the presence of NEXT-C-SID since it applies first */
> - if (seg6_next_csid_enabled(fops))
> + /* NEXT-C-SID is evaluated first, when configured */
> + if (seg6_use_next_csid(skb, finfo))
> return end_next_csid_core(skb, slwt);
>
> /* the specific processing function to be performed on the packet
> --
> 2.43.0
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Thanks
Hangbin
Technical Details
Message-ID:
<asyXpWXMeKnPw9U6@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-344793-linux-kernel-netdev=dewy.ruReferences:
<20261011192310.55-1-andrea.mayer@uniroma2.it> <20261011192310.55-4-andrea.mayer@uniroma2.it>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-344793-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 3/5] seg6: apply the PSP flavor together with NEXT-C-SID in SRv6 End Date: Mon, 12 Oct 2026 16:17:41 +0800 Organization: Usenet Network Message-ID: <asyXpWXMeKnPw9U6@fedora> References: <20261011192310.55-1-andrea.mayer@uniroma2.it> <20261011192310.55-4-andrea.mayer@uniroma2.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1716271"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:uQXTm2XsPM94cUDeNJ18OseFeLs= sha256:3Cxs7KEilDrBdg9OWeTFkleWHAoNXM2qX+QTmCgjS/s= sha1:VernCD7bf0UNPg+nunmKa8aV47c= sha256:eGIlnstwhIkO2hpItsg50tn3/ptn7Aj9LEimuDZ7k1o= 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 7B41510FB33; Mon, 12 Oct 2026 11:19:16 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -0.751 X-Spam-Status: No, score=-0.751 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, 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 8-kHjvKk7wZ5; Mon, 12 Oct 2026 11:19: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-344793-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 C6A1F10FB03; Mon, 12 Oct 2026 11:19:03 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 63B90394E2; Mon, 12 Oct 2026 08:17:54 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17105448CEC; Mon, 12 Oct 2026 08:17:54 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="r9Yw1yA4" X-Received: from mta1.migadu.com (out-153.mta1.migadu.com [95.215.58.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48E1B44A400 for <netdev@vger.kernel.org>; Mon, 12 Oct 2026 08:17:51 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.153 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791793074; cv=none; b=ieWqtyCAcU7iSkrHPh6byvcYVRWpbeDbptbPo0CJiM6F5dqwbZAxcIlwA8JgzUo5afAo1FU3T01zfLu4bifqudrTA4WZNUK/PLY/S60GLp+qFoHpL2WQ4YQbeScKOjNZrbAC2qH0DknHK5f8w4jAggShJG4Jr9ltgMuOfjGCAxc= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791793074; c=relaxed/simple; bh=oiQs+XaAPXnhj3q2rBXJEJ5pvTTgbC4S2aepl5uzLe4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=u1HzeZdMrYmvxiCrLLLIhaig+VRMLN118e9DkC4zCHPFtORXAEwchH/aIAdRj8Ns4XpSdfWoeMJJoaGC/j3VoJknNkpQll2mgc37qzoYlbdqLADVxBYbQrKQrP1o9/SlmVE1q5nuea7DU1RE/fDSk/O1bwkupBaWzX/QKVAqEI4= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=r9Yw1yA4; arc=none smtp.client-ip=95.215.58.153 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=oiQs+XaAPXnhj3q2rBXJEJ5pvTTgbC4S2aepl5uzLe4=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1791793069; v=1; x=1792397869; b=r9Yw1yA480UQrT66imwaLswS7CZn4oX+fMt7jmieYKMuZU4LQfE6oIIP5C7UCcXkKcDfehT8 eM10ev1x6JvfVP7/6/Jh8lDIFp3VxXpSVvFudxcXJc30IS+bKgxBOPdB7RHAXQ4xwDaPteHRUDn YO0wSWfo61PmlygbqCjc0ZCc= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta12.migadu.com with ESMTPS id 108c7064bb8ec50c; Mon, 12 Oct 2026 08:17:49 +0000 X-Mizu-Trace-ID: 108c7064bb8ec50c X-Migadu-Flow: FLOW_OUT X-Cc: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, David Ahern <dsahern@kernel.org>, Simon Horman <horms@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan <shuah@kernel.org>, Justin Iurman <justin.iurman@gmail.com>, Nicolas Dichtel <nicolas.dichtel@6wind.com>, Ahmed Abdelsalam <ahabdels@cisco.com>, Stefano Salsano <stefano.salsano@uniroma2.it> X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-In-Reply-To: <20261011192310.55-4-andrea.mayer@uniroma2.it>