Article View: linux.kernel.netdev
Article #10027Re: [PATCH net 3/6] seg6: update skb checksum when SRv6 behaviors advance to the next SID
From: Hangbin Liu
Date: Tue, 03 Nov 2026 02:15
Date: Tue, 03 Nov 2026 02:15
104 lines
12656 bytes
12656 bytes
Hi Andrea,
On Sat, Oct 31, 2026 at 11:50:30PM +0100, Andrea Mayer wrote:
> advance_nextseg() decrements Segments Left and writes the next segment into
> the destination address, and seg6_next_csid_advance_arg() advances the
> NEXT-C-SID argument in the destination address.
> With CHECKSUM_COMPLETE, neither updates skb->csum for these changes. The
> stale skb->csum is read when the packet is delivered on the same node, e.g.
> through End.B6.Encaps towards a local End.DT6 SID.
> As a consequence, when skb->csum is computed in software, for instance by
> conntrack, UDP can drop the packet as a checksum error. With skb->csum
> computed by the device, TCP can instead log a "hw csum failure", as if the
> device had computed a wrong skb->csum.
>
> Update skb->csum in both functions with update_csum_diff16() for the
> destination address. advance_nextseg() also uses update_csum_diff4() for
> Segments Left.
>
> Depends on patch "seg6: fix skb checksum update helpers".
>
> Found by manual code inspection while working on
> commit 8ae3f4067ba4 ("seg6: ensure packet data is writable before modifying
> SRH and IPv6 DA"), and reproduced in a VM without kernel changes or error
> injection. A following commit adds a selftest that reproduces the problem
> with a tc ct action. With this patch, the selftest passes for the
> End.B6.Encaps and next-csid paths. Also tested against the srv6 selftests,
> and with a ConnectX-6 Lx NIC (mlx5) that provides CHECKSUM_COMPLETE.
>
> Fixes: 140f04c33bbc ("ipv6: sr: implement several seg6local actions")
> Fixes: 848f3c0d4769 ("seg6: add NEXT-C-SID support for SRv6 End behavior")
> Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
> ---
> net/ipv6/seg6_local.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
> index 0c3d1be7f129..57a82477ce3f 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -291,7 +291,9 @@ static struct ipv6_sr_hdr *advance_nextseg(struct sk_buff *skb,
> struct ipv6_sr_hdr *srh,
> enum skb_drop_reason *reason)
> {
> + struct in6_addr *daddr;
> struct in6_addr *addr;
> + __be32 old;
> int srhoff;
> int wlen;
>
> @@ -309,10 +311,19 @@ static struct ipv6_sr_hdr *advance_nextseg(struct sk_buff *skb,
>
> /* skb_ensure_writable() may change skb pointers; evaluate srh again */
> srh = (struct ipv6_sr_hdr *)(skb->data + srhoff);
> + daddr = &ipv6_hdr(skb)->daddr;
> + /* nexthdr, hdrlen, type and segments_left */
> + old = *(__be32 *)srh;
>
> srh->segments_left--;
> addr = srh->segments + srh->segments_left;
> - ipv6_hdr(skb)->daddr = *addr;
> +
> + if (skb->ip_summed == CHECKSUM_COMPLETE) {
> + update_csum_diff4(skb, old, *(__be32 *)srh);
> + update_csum_diff16(skb, (__be32 *)daddr, (__be32 *)addr);
> + }
> +
> + *daddr = *addr;
Nit: we can re-use seg6_update_csum() if the transport header set correctly.
But that function is static and we need adjust header files.
So the current change looks good for me.
>
> return srh;
> }
> @@ -427,11 +438,13 @@ seg6_next_csid_advance_arg(struct sk_buff *skb,
> __u8 fnc_octects = seg6_flv_lcnode_func_octects(finfo);
> __u8 blk_octects = seg6_flv_lcblock_octects(finfo);
> struct in6_addr *addr;
> + struct in6_addr old;
>
> if (unlikely(skb_ensure_writable(skb, sizeof(struct ipv6hdr))))
> return SKB_DROP_REASON_NOMEM;
>
> addr = &ipv6_hdr(skb)->daddr;
> + old = *addr;
>
> /* advance DA.Argument */
> memmove(&addr->s6_addr[blk_octects],
> @@ -440,6 +453,9 @@ seg6_next_csid_advance_arg(struct sk_buff *skb,
>
> memset(&addr->s6_addr[16 - fnc_octects], 0x00, fnc_octects);
>
> + if (skb->ip_summed == CHECKSUM_COMPLETE)
> + update_csum_diff16(skb, (__be32 *)&old, (__be32 *)addr);
> +
> return SKB_NOT_DROPPED_YET;
> }
>
> --
> 2.43.0
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID:
<aulA09qBNtIxJq7S@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-355162-linux-kernel-netdev=dewy.ruReferences:
<20261031225033.64-1-andrea.mayer@uniroma2.it> <20261031225033.64-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-355162-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 3/6] seg6: update skb checksum when SRv6 behaviors advance to the next SID Date: Tue, 3 Nov 2026 10:15:03 +0800 Organization: Usenet Network Message-ID: <aulA09qBNtIxJq7S@fedora> References: <20261031225033.64-1-andrea.mayer@uniroma2.it> <20261031225033.64-4-andrea.mayer@uniroma2.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="3079028"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Nj/thxGuV5X1SEWMKGGscaYLgQo= sha256:0wwVt3e9ajT4M8bkv4coqABbVSWn3voEThzuWSTacgk= sha1:UNnQs+Atar6FUZe+YLaRBDmi5BQ= sha256:rufHG51DxNiD/XzUPJOyMvPOUxAXGBU07L/4R6G+3ZU= 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 8BA60112708; Tue, 3 Nov 2026 05:15:56 +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 xgxJz7IV0aYd; Tue, 3 Nov 2026 05:15:51 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-355162-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 8E0CF1126FF; Tue, 3 Nov 2026 05:15:42 +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 4EDDA299AE; Tue, 3 Nov 2026 02:15:25 +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=1793672123; b=Y/2vkE0CKg+AMSl2ewMSRbvs0I6aB2rQYXOz6UAR2FVYPmTj8odDk7GftEueVLPosrBP 6mx3Sk6lXA2tLw9ozz37cNjV1AMhmez5DLXn2Y6VSQDD6/zaZme9P9DVepnl3nt+U0ZEj VUpgUChXMu+kYCGvVJu4bRd4lKlhF5ydXDxIxFzXF3uXjDdEUF4HEvFKNfo1xx0bhl4Mt UYU7oINrn6dCX0J9ipVXapUH0vs6XOEH9vP6E7eg6wZRrxC0w3+Ure3ROMxonuLHB5BrG v3WGNowf5eiN8onU8UrzhzU2akRcVvpsck3L2xyX7ieOc7Lww28UapDcS26XTREugLA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793672123; 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:In-Reply-To; bh=swMBrZuLYQl7RYBGcyFALBP5NnR05K4Y76My6FBJtU0=; b=0z12RSjriAkO5XhHSSppPrQpwEagrpSwQYGzaj3C0h4wUCZSIxdJ1I+AEmPREtB6Uane /xlOROsb1NFmGc8VxspwvRkAvic/C/JYAyAf6ejTGI2D5E/5w1uLBiQz+T8pX6jgIHlmv 5mnr/3v/ytqCY+33fGiTqqmCVeGdDF+Fnuqv0YTzkB64MbaqhiZ5xTMGI0QnKVj/+d+zQ MgxMYY1Ryqt6CVPN56DijLu7g2fNXa+hEh7pWLfd5tf7bkYb4cSZ9odjEJks6fu4uNetU zhEJljBr02wJ9gYG/31UeW29aCfgFL8th07TYzeCrvNti/M1B908qOy5yMBI/BV2N4w== 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=lX4qJf0e; 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 E1280606D80D; Tue, 3 Nov 2026 02:15:22 +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=lX4qJf0e X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.75 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793672122; b=mPGDOT2UQp0frwiNa010VxO39bJsGRtvdngq3JuKpl5PWbLHkFKQ+Ln1uBqokgCYY3k+ Px6WIpEJZQolILm3ssVBJlismZ6hfr9ezSsdZjqiLxQBwhgwEF65w0JkNv8QvVYgnuDkX EWZwjJxrwkXBsjTWoX4hN6HFFRpmGThlfv5pY0h5mOrDXGZiAoyztI3en2DalcVkiJls7 nUuJuLZ829ttJoxS3KLk853isvRnRd0uMhfxIOYUaZQmrUyh7n3G1YHJzSwGJPL42xHdX PcFgCybXwov1BS0pRy4ropEtdN+m0VKpVyAG+5bkN6BZ4YuUy6VRrAwxkR3hFH3h51Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793672122; 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:In-Reply-To; bh=swMBrZuLYQl7RYBGcyFALBP5NnR05K4Y76My6FBJtU0=; b=HBUFbTa2q0OnwpfxCIPgK6QQo2vHnTUMITeLo0ZXdTV4p1/QZ6DxxbV+CaEtIr//tIzR YebpQhmtbcj07F31/Wr+2t2jO25OdZ38lv3YAQfZi4vh3pb0V98xAqINgtwKFXPfOPz2d n+UMuZf2aOABn5gHdew5f1Fph0NctzBAtg+5NscqBuyo/hTaCd+zLX3h3gO7+Cr2y6Ax5 MqqOvo9UZObJpaZLU3+i9ZTtUcfpKw/cKPxp3h31f3nxBQqUEZ9Ot9MieB83U5sV0CcF2 EOEVMfnbT1wpJQfk87EH51d15Bxv00qr7HZYANsRCZ/mneppluLdj5oU/xoQuc/lhrg== 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=lX4qJf0e; arc=none smtp.remote-ip=91.218.175.75 X-Received: from mta0.migadu.com (out-75.mta0.migadu.com [91.218.175.75]) (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 43617606A331 for <netdev@vger.kernel.org>; Tue, 3 Nov 2026 02:15:20 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 43617606A331 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=Z4q8r55MMjPLd9lBbgy0/F1GPB2LJsVrIvS8JZYXVIM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793672119; v=1; x=1794276919; b=lX4qJf0evWkWo2H1GzdHljzs7DptE1ZYrRbf8XisV/6XjG1cxnHYRhmmVUWcCY8tKdmyuoP2 C/LAmXc7JadQV4BZR++4X9gTsqc8mVhmW9xcw7rlz8NHNS85TPF1wyRIM1FfbDU8M0Hgj+oor4L ZfC4OZaZ+0qyvGEzfhUwqhWY= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta12.migadu.com with ESMTPS id 635985c26460c19e; Tue, 03 Nov 2026 02:15:16 +0000 X-Mizu-Trace-ID: 635985c26460c19e 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>, Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>, Ido Schimmel <idosch@nvidia.com>, Shuah Khan <shuah@kernel.org>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, David Lebrun <david.lebrun@uclouvain.be>, Daniel Borkmann <daniel@iogearbox.net>, Mathieu Xhonneux <m.xhonneux@gmail.com>, David Lebrun <dlebrun@google.com>, Stefano Salsano <stefano.salsano@uniroma2.it>, Andrea Mayer <andrea@common-net.org> 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: <20261031225033.64-4-andrea.mayer@uniroma2.it>