Article View: linux.kernel.netdev
Article #19059Re: [PATCH net v2 6/6] selftests: seg6: add test for skb checksum with CHECKSUM_COMPLETE
From: Hangbin Liu
Date: Thu, 19 Nov 2026 09:20
Date: Thu, 19 Nov 2026 09:20
145 lines
13090 bytes
13090 bytes
Hi Andrea,
On Wed, Nov 18, 2026 at 04:02:51PM +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@uniroma2.it>
> ---
Here are some code style comments. You can decide whether to change them or not.
>
> +print_log_test_results()
> +{
> + printf "\nTests passed: %3d\n" "${nsuccess}"
> + printf "Tests failed: %3d\n" "${nfail}"
> +
> + # when a test fails, the value of 'ret' is set to 1 (error code).
> + # Conversely, when all tests are passed successfully, the 'ret' value
> + # is set to 0 (success code).
> + if [ "${ret}" -ne 1 ]; then
> + ret=0
> + fi
Do we need to reset the "ret"? It's $ksft_skip by default. If any test failed,
it is set to $ksft_fail. We can just exit with $ret at cleanup().
> +
> +cleanup()
> +{
> + cleanup_all_ns
> +
> + # check whether the setup phase was completed successfully or not. In
> + # case of an error during the setup phase of the testing environment,
> + # the selftest is considered as "skipped".
> + if [ "${SETUP_ERR}" -ne 0 ]; then
> + echo "SKIP: Setting up the testing environment failed"
> + exit "${ksft_skip}"
if [ "${SETUP_ERR}" -ne 0 ], the ret should be ${ksft_skip}, right? Cause
we haven't run any test.
Then we can goto the following exit directly.
> + fi
> +
> + exit "${ret}"
> +}
> +
[...]
> +test_end_bpf_or_ksft_skip()
> +{
> + local test_netns
> +
> + setup_ns test_netns
> +
> + ip -netns "${test_netns}" link add "${DUMMY_DEVNAME}" type dummy
> + ip -netns "${test_netns}" link set "${DUMMY_DEVNAME}" up
> +
> + if ! ip -netns "${test_netns}" -6 route \
> + add "${SID_LOCATOR}::${BPF_FUNC}/128" encap seg6local \
> + action End.BPF endpoint obj "${BPF_FILE}" \
> + sec "${BPF_END_SEC}" dev "${DUMMY_DEVNAME}" \
> + 2>/dev/null; then
> + cleanup_ns "${test_netns}"
> + echo "SKIP: SRv6 End.BPF not supported"
> + exit "${ksft_skip}"
> + fi
> +
> + cleanup_ns "${test_netns}"
> +}
Maybe move the `trap cleanup EXIT` here.
Then we can just `exit` instead of `exit "${ksft_skip}"` for all the
test_* functions. The cleanup_all_ns() will just do nothing when the
NS_LIST is NULL.
If a command missing, or test_* function failed. The report shows
SKIP: xxx not supported
SKIP: Setting up the testing environment failed
# echo $?
4
> +
> +if [ "$(id -u)" -ne 0 ]; then
> + echo "SKIP: Need root privileges"
> + exit "${ksft_skip}"
> +fi
> +
> +# required programs to carry out this selftest
> +require_command ip
> +require_command tc
> +require_command ethtool
> +require_command ping
> +require_command sysctl
> +require_command awk
> +require_command grep
> +
> +test_dummy_dev_or_ksft_skip
> +test_iproute2_supp_or_ksft_skip
> +test_kernel_supp_or_ksft_skip
> +test_veth_tx_csum_off_or_ksft_skip
> +test_bpf_file_or_ksft_skip
> +test_tc_or_ksft_skip
> +test_end_bpf_or_ksft_skip
> +
> +set -e
> +trap cleanup EXIT
> +
> +setup
> +set +e
> +
> +connectivity_tests
> +udp_delivery_tests
> +
> +print_log_test_results
> --
Apart from the comments, the test looks good to me.
Tested-by: Hangbin Liu <liuhangbin@kylinos.cn>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID:
<av6_eqt8yH5qmLYL@fedora>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366881-linux-kernel-netdev=dewy.ruReferences:
<20261118150251.65-1-andrea.mayer@uniroma2.it> <20261118150251.65-7-andrea.mayer@uniroma2.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366881-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 6/6] selftests: seg6: add test for skb checksum with CHECKSUM_COMPLETE Date: Thu, 19 Nov 2026 17:20:58 +0800 Organization: Usenet Network Message-ID: <av6_eqt8yH5qmLYL@fedora> References: <20261118150251.65-1-andrea.mayer@uniroma2.it> <20261118150251.65-7-andrea.mayer@uniroma2.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="2837458"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:IU9dmdOrdH0hrEhVPpab5sTBR8c= sha256:inTkyFm1IhwecP96U/qGYRyPnSLBoyQu4sc0sYlkK8Q= sha1:5t2g67QocSO6+BSPS5AgqyipP9o= sha256:CtTpcdJDwlEDJhztJv+I7Ijlb8+Nzn38+thB+5MYkwA= 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 B16C011557E; Thu, 19 Nov 2026 12:21:42 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 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, 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 jJ4yWgrfF95p; Thu, 19 Nov 2026 12:21:39 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366881-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id C0660115572; Thu, 19 Nov 2026 12:21:29 +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 048F682F79; Thu, 19 Nov 2026 09:21:27 +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=1795080084; b=41C/vEXB+s3KLu6+kWN43qZUYEnEx1pVrE6oiEPwmboBctSHZKKMWocX63pDQwHBob3b py9rtd594uJJl3p1yBSkUKYI7cr43NGAGOdNEmYIZ6yvOJJPdCbDUBN8OUR5ovdN3WNQy lrX5TVki+O3FCZXR2mUgRTo5H559LBvXjl3DF0dlRcvahXjZqAxk8PXcbTFEcUeECgwrr jV0wes6dR0JA7fJW5Gt4mU3pIKQe+r4bh2RaPpeHzqiA2pRdpuhR1Sfe/H5fO16Da5Tpn zo6lAGZXaYC9uqdzkcZ1iGgPwl5zahpAgxPvkfO7q8oLP1Gk0dI+RUnphc6nm1IHkvA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795080084; 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=jwlrWkiL6/bc8bt3jFA1PNWrJYj2IlYZaoWgGCfb8oM=; b=rzRF03Eq0CGf6/kd8Go+rMtK9KgH6pjT7UCk9ntD9v9LosgmLC4P0aNHAh1J2zoLlM1C qsClqSmRBjAE1vwpRO91gEWdOy/qnu3jZxgIirNMHVZseCsAg5oSPNgqgZWt2cthaHzPr Pr9ACJzRPr800NCrLC+QE24ZkH9KoMJUsCqYht33jgLJQOpjX9+P59ytrGUavxiRY6rbo jmIA9TUHT2xnOv3NwbPTEgs2bPQzVS2mfsoI4LV0qK5KLRHEZDorNDveGvPwSaQFJRJBa Mf620rYQ5wXxXHmAG/telq0pkr6k9VHfKB2S3a43n2fsTnA9tDWNh6uA+aw5U4oW0wA== 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=aWlX8672; 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 B0962606A339; Thu, 19 Nov 2026 09:21:24 +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=aWlX8672 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.16 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795080083; b=SofEj2+NagurrbhhT9Mu3docIdLurAhFa/BhVayd3Zq1tzli+1qwimrjCAMWqceYT8PQ bSPScuFyPI6o095OyG00c0OqZmvzrkQ2gs6onF4Ic8+aBTmXkryEH0TAmBTiIIA7XiWDP 8n0qb1+Cq5lNl+CHDRaqPe15WfkzrQnVoy7Rrytb+QM4BUg3Nmgq4r2mXHst9HD1qaYHA b7X6+MKGqgXOMuZgW9V2jH2dj1JcI8xqUpoet0kANaAXZhsSF/Oh9IC++pjDiBNgvcPPS T0Ew0ItRs+f5NDwNl4jCqW/sJUufmLZ1XGgS0zGf1nfRb7bhXeFZrZRC9g6lPLtOLCA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795080083; 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=jwlrWkiL6/bc8bt3jFA1PNWrJYj2IlYZaoWgGCfb8oM=; b=H8Rzao0gd5vBvDoilGL4iT6ID+sM1HwpfUpmUENlbd4dUuyfzWLHrsRMFbBWmJ/UVJkw +N0ZegPoixwu62+uIM54Knc6m97fRWd60s0V73rSWwW0r1RQJZzBRTM3x+r/VofsoOuaE ct/LRGxzF3h3P0RkgLP9RFXxin1oWTs6pPC4ksKGRbDQGW4k7ysYqSodGhBQLwYu7JNF9 r80PV9YB0OqSA4bPTBPjlySU6aTJV37ejsYlrPvmmPw66VQlnaEY/YUfsTN2BpatGxzAD sJff0JUhby/o2WQ2dHKtQZ4b1aFRZu3DocwM3lnT/cgpNYPkAc/FNCVuD6NZzSacTaw== 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=aWlX8672; arc=none smtp.remote-ip=91.218.175.16 X-Received: from mta0.migadu.com (out-16.mta0.migadu.com [91.218.175.16]) (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 F0A12606A320 for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 09:21:22 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F0A12606A320 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=mPiSiO8g+w2DpPp3GGR8IZ3wJAak28Y/ctpnaig1pAM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795080081; v=1; x=1795684881; b=aWlX8672Mj+HReGYIkiRRIhO2O6zkeJuL6VhFnecacKIcpMy2KcYJl0JkXPRJ0jF0WUoCHWX UZp2CZnznB6IlqTgWp6la/ZxlGdmw4GmoBiVritBCyH+02wWoB+Yb4mtGqT+mjjfUm/Hc4tgNEi T6rNUYUNQGTJDUl+RDKOLWU8= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta10.migadu.com with ESMTPS id 291b443669a991fd; Thu, 19 Nov 2026 09:21:20 +0000 X-Mizu-Trace-ID: 291b443669a991fd 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>, Justin Iurman <justin.iurman@gmail.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: <20261118150251.65-7-andrea.mayer@uniroma2.it>