Article View: linux.kernel.netdev
Article #9208[PATCH net 3/6] seg6: update skb checksum when SRv6 behaviors advance to the next SID
From: Andrea Mayer
Date: Sat, 31 Oct 2026 22:50
Date: Sat, 31 Oct 2026 22:50
94 lines
13336 bytes
13336 bytes
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;
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
Technical Details
Message-ID:
<20261031225033.64-4-andrea.mayer@uniroma2.it>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354161-linux-kernel-netdev=dewy.ruReferences:
<20261031225033.64-1-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-354161-linux-kernel-netdev=dewy.ru
From: andrea.mayer@uniroma2.it (Andrea Mayer)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 3/6] seg6: update skb checksum when SRv6 behaviors advance to the next SID
Date: Sat, 31 Oct 2026 23:50:30 +0100
Organization: Usenet Network
Message-ID: <20261031225033.64-4-andrea.mayer@uniroma2.it>
References: <20261031225033.64-1-andrea.mayer@uniroma2.it>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2572075"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:eBd1YS2VgSieI5FYMmsbr0cx1Mw= sha256:XbB4umWv3JD7CSG850fMHwtSTLLNAYyW0oRBb85tdgo=
sha1:JtK+MSwFTL8MTYU0bH3TqAtV8jw= sha256:auTAx9NCEauuyb+U+bbB9MvUuERIHkNdFYfuaQ+7md4=
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 E063F1122BD; Sun, 1 Nov 2026 01:53:34 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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.25,
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=neutral
reason="invalid (unsupported algorithm ed25519-sha256)"
header.d=uniroma2.it header.b=hTbAoPyJ; dkim=pass (2048-bit key)
header.d=uniroma2.it header.b=lIOa1BSD
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 xcSPSHxW4Rum;
Sun, 1 Nov 2026 01:53:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-354161-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=uniroma2.it
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id D81C1112025; Sun, 1 Nov 2026 01:53:13 +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 244AB2AFA5; Sat, 31 Oct 2026 22:52: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=1793487143;
b=bJQMV9pA9FxZCc4CVwhNvo+8tLv6CY3CSktWUwZ9B9rVd7ERWwMEOtrizwal6iIsFLML
0zsfCA/A9YZiDyeioZD2ZQ8K+XIeqV6QgjRhlubA1amvxXrevuHCpmNS3rZ7NtzYDnrp0
erLp/pY+mRk2iEl7M8BrhW0TUD8beGTjuBc1TYZ+FBKUsfTG/FafibyPU99ZCT3+yNk/t
5fyuoneSBgPURLD4xKnG/r/ZCeZwU1QrKo1A8/6iSf55qhAGL2pPieWX2XOn2Z6dbu58g
f0fVPIPbU84cLlD1H9yo9ghFyoEhkMeqBnfbeFVLxgj6+weoI24nftrTMMbBeMeicnQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793487143;
h=X-Original-To:Received:DMARC-Filter:Received:Received:DKIM-Signature:
DKIM-Signature:From:To:Cc:Subject:Date:Message-Id:X-Mailer:
In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding:X-Virus-Scanned:X-Virus-Status;
bh=i0mRX4c0BcWn8yJMg1vJD0MU4olefXJx+DZ7RZh2hU8=;
b=rA9Gzqt7Yv+/V/nn5DI4Bca0tTENtQLBXdbB3lsPBRckH2pEV2Qzeobekbe6KkxAhQ+D
HWxiQxFDXP8fgjaQeexnBeGSpn3Qr90mmHTtlLFZqmiLer+qzwuO6R1K+eRdpQLlMXDcQ
8i9v6FBpjsvIE2CsjFyWjA9v/p+EOAUvt+7kxHKHSC4tuBiTkUepa7foZjfcSuavu8H5j
tc8kySP6hyqAaL465CdSB3bUZB4vJ5edZy8CcU1p5sonEJK2yJn7Juiz1iD5f3qr28akO
ukUSp7dBR0WqedBGSKuk4TcxnEbBcQKrwot9LYW9cLZSN6ewQF8pRbBJ5vdvomo7MgA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=hTbAoPyJ;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b=lIOa1BSD;
dmarc=pass header.from=uniroma2.it;
spf=pass smtp.mailfrom=uniroma2.it;
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 441A660A2612;
Sat, 31 Oct 2026 22:52:23 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=hTbAoPyJ;
dkim=pass (2048-bit key, unprotected) header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b=lIOa1BSD
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=160.80.4.37
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793487142;
b=QP5LZ0VfsyMWF0JJGnJac3uCngqjNb4EssSQqUQg8nue1kg+O37Q5Nylm4rZdH/Dak1d
bRXxkHqwxPuHhZVOtgXLlORZDc21DCpoiF3hJpeck5d3r/EJ/KuhVRYA5aMD0nCqr/qcZ
UTT5lWw+0n1oYO81ZPDXhWmiU8LmLsbBe6U9RBEyWlakfvKJJNIhv1aY5odkef+IbjZe8
S/0SDTku3MUk3IDQBC98aPnOFgfYOV5u0MHQK3m7FqhPfEJwioP8yrJrRDlL49RhS8rT5
NgR7ZgziPD9JiYG83hCn1rtdCPN98eY2kcnn97N1kCR0sqLVqpR0FyyKECN0Qewc8NA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793487142;
h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature:From:To:
Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:
MIME-Version:Content-Transfer-Encoding:X-Virus-Scanned:
X-Virus-Status;
bh=i0mRX4c0BcWn8yJMg1vJD0MU4olefXJx+DZ7RZh2hU8=;
b=tAI2AQxpfrjwhzfYJEKOS7bJGzpFkJ7l/1hY/cIVglgKxdJrcz4mU8KcdJdx8HO62mg9
/q5knNrWLToqqP4WpDZPES3tkzvonbjX9J9b4YS+fH9xgqiMiIVdy4SCo8eskf81KrsFC
838hlfcQqJwkASTyIuf1sDtqdLNfumUDeqI4V7a02dFzVF1YuEugLUILr4s8KhoAuzMiX
7r2aHSIdZsECWQrfHB92LlKjX4U/24UvodMutPB1vrFy3DeK878tI+YWfj3465JGIvj17
bMilBVqisv7o58mrnPjKyNKvYINq9ZpQLRYQ31xMR1RmkhlS3zn9eLN6l58Oztjk+MA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=uniroma2.it;
spf=pass smtp.mailfrom=uniroma2.it;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=hTbAoPyJ;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b=lIOa1BSD;
arc=none smtp.remote-ip=160.80.4.37
X-Received: from smtp.uniroma2.it (smtp.uniroma2.it [160.80.4.37])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 2455D606A31E;
Sat, 31 Oct 2026 22:52:18 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2455D606A31E
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniroma2.it
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniroma2.it
X-Received: from smtpauth-2019-1.uniroma2.it (smtpauth.uniroma2.it [160.80.5.46])
by smtp-2015.uniroma2.it (8.14.4/8.14.4/Debian-8) with ESMTP id 69VMpGrg021944;
Sat, 31 Oct 2026 23:51:21 +0100
X-Received: from localhost.localdomain (unknown [160.80.105.87])
by smtpauth-2019-1.uniroma2.it (Postfix) with ESMTPSA id D2A60122943;
Sat, 31 Oct 2026 23:51:11 +0100 (CET)
X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=uniroma2.it;
s=ed201904; t=1793487071; h=from:from:sender:reply-to:subject:subject:date:date:
message-id:message-id:to:to:cc:cc:mime-version:mime-version:
content-type:content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references;
bh=i0mRX4c0BcWn8yJMg1vJD0MU4olefXJx+DZ7RZh2hU8=;
b=hTbAoPyJjBwdNPuAHH7yB+iAZkiooVuqxDkAnR+deoCZC2o8s1NlTWPErUkDey/t3VGT+J
TeKhO2slr+9mTQDg==
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniroma2.it; s=rsa201904;
t=1793487071; h=from:from:sender:reply-to:subject:subject:date:date:
message-id:message-id:to:to:cc:cc:mime-version:mime-version:
content-type:content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references;
bh=i0mRX4c0BcWn8yJMg1vJD0MU4olefXJx+DZ7RZh2hU8=;
b=lIOa1BSDLk62ctwPmwpPSpfCZ4MxFP530wP5uVVdgUNOw3Vti8DEwnoVce1xI40awGpG2O
dHjqGzZTk/JUQwyb6ihYcL8HAuupe6m60MgczcQDs5GTSoOUDHhCkM/hh4n1L93V7mEIt1
ppcNuKJ6XhaA82uCqqxUaFI9Yk4Kagf+MHklebI7DYrbpqQAzi5ex8llq187SwABDrECr5
we7gh9mnB2lE0JoJoQHiMtcLpWDZw4HeV5MFIX02edtXk5n5Baw7t7riAqgilh/0KWUaU5
9fUEG6qtCnr34GSFNu/hgdZ7vQhGEQuXr0QnpR0fSzW/QSVsgBiIK3Lke5F3yg==
X-Cc: 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>, Hangbin Liu <hangbin.liu@linux.dev>,
Stefano Salsano <stefano.salsano@uniroma2.it>,
Andrea Mayer <andrea@common-net.org>,
Andrea Mayer <andrea.mayer@uniroma2.it>
X-Mailer: git-send-email 2.39.5
X-In-Reply-To: <20261031225033.64-1-andrea.mayer@uniroma2.it>
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-Virus-Scanned: clamav-milter 0.100.0 at smtp-2015
X-Virus-Status: Clean