Article View: linux.kernel.netdev
Article #2165Re: [PATCH net-next 1/5] seg6: handle a Fragment or AH header before the SRH consistently in PSP
From: Hangbin Liu
Date: Mon, 12 Oct 2026 07:59
Date: Mon, 12 Oct 2026 07:59
78 lines
9041 bytes
9041 bytes
On Sun, Oct 11, 2026 at 09:23:06PM +0200, Andrea Mayer wrote:
> seg6_pop_srh() already fails when a Fragment or AH header comes before
> the SRH with other headers in between, and the packet is dropped ("we
> expect SRH before FRAG and AUTH" in the code). But when the SRH directly
> follows the Fragment or AH header, it is removed:
>
> (a) IPv6 | FRAG/AH | DOPT | SRH | ... the packet is dropped
> (b) IPv6 | FRAG/AH | SRH | ... the SRH is removed
>
> In both packets the Fragment or AH header comes before the SRH.
>
> Align the two cases: check first whether a header is a Fragment or AH
> header, and only then look at its Next Header field. In this way, the
> packet is dropped also when the Fragment or AH header comes directly
> before the SRH. A Fragment or AH header before the SRH, with or without
> other headers in between, does not follow RFC 8200 and RFC 4302: a
> Fragment header must not come before the Routing header, as the
> Per-Fragment headers must include the Routing header [1], and AH should
> not come before the routing and fragmentation headers [2].
>
> At the penultimate segment, End with the PSP flavor alone today drops
> (a) and forwards (b) with the SRH removed. Packets with the Fragment or
> AH header after the SRH are not affected: seg6_pop_srh() does not look
> at the headers after the SRH.
>
> Found by manual code inspection and reproduced in a VM without kernel
> changes or error injection, by sending to End with PSP the packets
> shown in the diagram, both with a Fragment header and with AH. With this
> change, the packets are dropped in both cases, all tests in
> srv6_end_flavors_test.sh pass, and KASAN reports no error. With the
> whole series, all the srv6_*.sh selftests pass.
>
> [1] - https://datatracker.ietf.org/doc/html/rfc8200#section-4.5
> [2] - https://datatracker.ietf.org/doc/html/rfc4302#section-3.1.1
>
> 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 | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
> index 0c3d1be7f129..da8225591fe3 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -796,11 +796,6 @@ static bool seg6_pop_srh(struct sk_buff *skb, int srhoff)
> if (unlikely(!hp))
> return false;
>
> - if (hp->nexthdr == NEXTHDR_ROUTING) {
> - hp->nexthdr = srh_nexthdr;
> - break;
> - }
> -
> switch (nexthdr) {
> case NEXTHDR_FRAGMENT:
> fallthrough;
> @@ -812,6 +807,11 @@ static bool seg6_pop_srh(struct sk_buff *skb, int srhoff)
> break;
> }
>
> + if (hp->nexthdr == NEXTHDR_ROUTING) {
> + hp->nexthdr = srh_nexthdr;
> + break;
> + }
> +
> nexthdr = hp->nexthdr;
> }
> }
> --
> 2.43.0
>
After changing the order, we can check the FRAG/AH header first and
return false and drop the pkt.
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID:
<asyTTOcu2MRufGJ-@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-344780-linux-kernel-netdev=dewy.ruReferences:
<20261011192310.55-1-andrea.mayer@uniroma2.it> <20261011192310.55-2-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-344780-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 1/5] seg6: handle a Fragment or AH header before the SRH consistently in PSP Date: Mon, 12 Oct 2026 15:59:08 +0800 Organization: Usenet Network Message-ID: <asyTTOcu2MRufGJ-@fedora> References: <20261011192310.55-1-andrea.mayer@uniroma2.it> <20261011192310.55-2-andrea.mayer@uniroma2.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1712445"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Lydap6eZMotfp5m29cfPiCU57Rw= sha256:xoo1O2VFD8iCXqVjPv2eW3kEhNBQvnKNNVMprtVSmn0= sha1:5aqGIJ2wU/OXQfi3zSAAbPCRw6A= sha256:j94LO3vmz/PeRhM40eEYNT8GQUGrutOe7KvXuycu5oQ= 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 7E97010FB25; Mon, 12 Oct 2026 10:59:40 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -0.75 X-Spam-Status: No, score=-0.75 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, URIBL_BLOCKED=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 nPDYrZ8Y0IL1; Mon, 12 Oct 2026 10:59:37 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-344780-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id B015610FB20; Mon, 12 Oct 2026 10:59:28 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 1EBCB26625; Mon, 12 Oct 2026 07:59:26 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A775144A3FF; Mon, 12 Oct 2026 07:59:24 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Pj/btZnL" X-Received: from mta0.migadu.com (out-70.mta0.migadu.com [91.218.175.70]) (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 CF92344AB7D for <netdev@vger.kernel.org>; Mon, 12 Oct 2026 07:59:19 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.70 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791791964; cv=none; b=mJkgpZwDfeuHhSJhkUksoepMY02Sn08plLayT4oDFnn07ot5zMGWaC0h9PgMc2UkbFIZPIXovqnW69M38qh1fWpRuXzcfrwqP5oUT5o9LewW7QDc5SrvzhiqqJu+4BGValwIPq7ZedJ1m1DpUk1FUOQEwTHk6QeQxm66mQbfhWc= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791791964; c=relaxed/simple; bh=56McHLpkjbEcfgo3ET0BWRpRsj/vdI3JWjyVwnemna0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hNZ1qutfH2Mzuj7DOo7VZsY5r+CR0y+Ge2QYQrcwgAWtkYp1xfE5tTILpO+8xGAdDuMhl34Vr3DuXw0evAAmFR3KAJ7uPkBT8ub270Me3tq8Pu9PMBGf0pWWcWyyYoArqn0yQI2u9x7OKuxLoUuVbc495QdqFS/Yek6TMIuc+4g= 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=Pj/btZnL; arc=none smtp.client-ip=91.218.175.70 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=56McHLpkjbEcfgo3ET0BWRpRsj/vdI3JWjyVwnemna0=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1791791957; v=1; x=1792396757; b=Pj/btZnLyrKTvemqk0Widq6ALB5WUmpF8p1x6BmbzwaXiDAFU2a4zPVP8QvoznbLX1LR6ZPj 5N9sLp8Y+HG+C/Klzzxu/bxZhiy7tb2IHzd49kNOuZF8UW+2suDqPdZNp+g48obqkRT6eoL7OmL N23mIKLTbHjd+/Vc+qSP1UaY= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta12.migadu.com with ESMTPS id 0f422274027c2e95; Mon, 12 Oct 2026 07:59:16 +0000 X-Mizu-Trace-ID: 0f422274027c2e95 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-2-andrea.mayer@uniroma2.it>