From: Andrea Mayer <andrea.mayer@uniroma2.it>
To: "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>
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>
Subject: [PATCH net 0/6] seg6: fix skb checksum updates with CHECKSUM_COMPLETE
Date: Sat, 31 Oct 2026 23:50:27 +0100 [thread overview]
Message-ID: <20261031225033.64-1-andrea.mayer@uniroma2.it> (raw)
This series fixes the skb->csum updates with CHECKSUM_COMPLETE when the
SRv6 code processes a received packet. In several places skb->csum is not
updated correctly:
- ipv6_srh_rcv() updates skb->csum with the wrong sign for the new
Segments Left and destination address, and not at all for the Hop Limit
decrement.
- advance_nextseg() and seg6_next_csid_advance_arg() in seg6_local do
not update skb->csum.
- The End.BPF program and seg6_bpf_has_valid_srh() can change the
packet without updating skb->csum.
- In L2ENCAP and L2ENCAP_RED mode, the MAC header put back in front of
the frame is not added to skb->csum.
When the packet is then delivered on the same node, the effect depends on
who computed skb->csum. With skb->csum computed in software, for example by
conntrack, UDP can drop the packet as a checksum error. With skb->csum
computed by the device, TCP can log a "hw csum failure", as if the device
had computed a wrong skb->csum. In the L2ENCAP case skb->csum can be read
on local delivery, for example by a raw socket with IPV6_CHECKSUM.
The series is organized as follows:
- Patch 1/6 fixes the update_csum_diff4() and update_csum_diff16()
helpers.
- Patch 2/6 updates skb->csum for the Hop Limit decrement in
ipv6_srh_rcv().
It depends on patch 1/6.
- Patch 3/6 updates skb->csum when SRv6 behaviors advance to the next SID.
It depends on patch 1/6.
- Patch 4/6 discards CHECKSUM_COMPLETE after the End.BPF program.
- Patch 5/6 accounts for the MAC header in skb->csum on L2 encapsulation.
- Patch 6/6 adds a selftest that uses a tc ct action to compute skb->csum.
It covers the paths of patches 1/6 to 4/6, and a control datagram
checks that the test detects a wrong skb->csum.
Tested with the srv6_*.sh selftests, including the new one, and with the
lwt_seg6local BPF selftest. The series was also tested with a ConnectX-6 Lx
NIC (mlx5) that provides CHECKSUM_COMPLETE. Without the series, TCP over
the SRv6 paths of patches 1/6 to 4/6 can log "hw csum failure". The same
happens for a raw socket with IPV6_CHECKSUM, on a packet delivered locally
after L2ENCAP. With this series, none of this happens.
Thanks,
Andrea
Andrea Mayer (6):
seg6: fix skb checksum update helpers
seg6: update skb checksum when ipv6_srh_rcv() decrements the Hop Limit
seg6: update skb checksum when SRv6 behaviors advance to the next SID
seg6: discard CHECKSUM_COMPLETE after the End.BPF program
seg6: account for the MAC header in skb checksum on L2 encapsulation
selftests: seg6: add test for skb checksum with CHECKSUM_COMPLETE
include/net/seg6.h | 4 +-
net/ipv6/exthdrs.c | 8 +
net/ipv6/seg6_iptunnel.c | 2 +-
net/ipv6/seg6_local.c | 24 +-
tools/testing/selftests/net/Makefile | 1 +
.../selftests/net/srv6_csum_complete.bpf.c | 65 ++
.../selftests/net/srv6_csum_complete_test.sh | 642 ++++++++++++++++++
7 files changed, 742 insertions(+), 4 deletions(-)
create mode 100644 tools/testing/selftests/net/srv6_csum_complete.bpf.c
create mode 100755 tools/testing/selftests/net/srv6_csum_complete_test.sh
--
2.43.0
next reply other threads:[~2026-10-31 22:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 22:50 Andrea Mayer [this message]
2026-10-31 22:50 ` [PATCH net 1/6] seg6: fix skb checksum update helpers Andrea Mayer
2026-11-03 1:25 ` Hangbin Liu
2026-10-31 22:50 ` [PATCH net 2/6] seg6: update skb checksum when ipv6_srh_rcv() decrements the Hop Limit Andrea Mayer
2026-11-03 1:27 ` Hangbin Liu
2026-10-31 22:50 ` [PATCH net 3/6] seg6: update skb checksum when SRv6 behaviors advance to the next SID Andrea Mayer
2026-11-03 2:15 ` Hangbin Liu
2026-10-31 22:50 ` [PATCH net 4/6] seg6: discard CHECKSUM_COMPLETE after the End.BPF program Andrea Mayer
2026-11-03 2:28 ` Hangbin Liu
2026-10-31 22:50 ` [PATCH net 5/6] seg6: account for the MAC header in skb checksum on L2 encapsulation Andrea Mayer
2026-11-03 2:37 ` Hangbin Liu
2026-10-31 22:50 ` [PATCH net 6/6] selftests: seg6: add test for skb checksum with CHECKSUM_COMPLETE Andrea Mayer
2026-11-03 3:26 ` Hangbin Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261031225033.64-1-andrea.mayer@uniroma2.it \
--to=andrea.mayer@uniroma2.it \
--cc=andrea@common-net.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=david.lebrun@uclouvain.be \
--cc=dlebrun@google.com \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=hangbin.liu@linux.dev \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=m.xhonneux@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=stefano.salsano@uniroma2.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®