Re: [PATCH net 6/6] selftests: seg6: add test for skb checksum with CHECKSUM_COMPLETE

From: Hangbin Liu

Date: Mon Nov 02 2026 - 22:27:16 EST


Hi Andrea,
On Sat, Oct 31, 2026 at 11:50:33PM +0100, Andrea Mayer wrote:
> Add a selftest for received packets with CHECKSUM_COMPLETE that the SRv6
> code processes before they are delivered on the same node. The test checks
> that, after the node changes the packet, UDP does not read a wrong
> skb->csum.
>
> The test uses a host and a router connected through a veth pair. Since veth
> does not provide CHECKSUM_COMPLETE, a tc ct action on the router computes
> skb->csum in software.
>
> The host sends a UDP datagram to the router along five paths: no SRH (the
> reference), an SRH with local segments, End.B6.Encaps with End.DT6, End
> with the next-csid flavor, and End.BPF. Each datagram is expected to be
> delivered, not dropped as a checksum error. Without the previous patches,
> every path except the reference fails. With them, every path passes.
>
> The host also sends a control datagram. It checks that the test detects a
> wrong skb->csum after a change to the packet. After the ct action, a BPF
> program on the router changes the Flow Label of the control datagram
> without updating skb->csum, and UDP must drop it. If UDP accepts it, the
> paths above may report a false pass, and the test fails.
>
> Signed-off-by: Andrea Mayer <andrea.mayer@xxxxxxxxxxx>
> ---
> tools/testing/selftests/net/Makefile | 1 +
> .../selftests/net/srv6_csum_complete.bpf.c | 65 ++
> .../selftests/net/srv6_csum_complete_test.sh | 642 ++++++++++++++++++
> 3 files changed, 708 insertions(+)
> create mode 100644 tools/testing/selftests/net/srv6_csum_complete.bpf.c
> create mode 100755 tools/testing/selftests/net/srv6_csum_complete_test.sh
>

[...]

> +
> +log_test()
> +{
> + log_test_expected "$1" "$2" "$3"
> +}

We'd better use log_test_expected directly, otherwise the log_test in
lib.sh will be overwrite.

> +
> +test_command_or_ksft_skip()
> +{
> + local cmd="$1"
> +
> + if [ ! -x "$(command -v "${cmd}")" ]; then
> + echo "SKIP: Could not run test without \"${cmd}\" tool"
> + exit "${ksft_skip}"
> + fi
> +}

Then we can use require_command() in lib.sh here, which will call
log_test() in lib.sh.

[...]

> +
> +if [ "$(id -u)" -ne 0 ]; then
> + echo "SKIP: Need root privileges"
> + exit "${ksft_skip}"
> +fi

I wonder if there is any one run the selftest with none root privileges.
Cause almost all the selftests need ip configurations.

Thanks
Hangbin