[PATCH net-next v2 2/2] selftests: net: Exercise TCP payload verification in udpgso_bench.sh

From: shuo huang

Date: Fri Sep 11 2026 - 12:50:30 EST


The benchmark script does not exercise TCP payload verification.

Add a verification case for IPv4 and IPv6 using 100 4 KiB payloads.
The payload length is not a multiple of 26, allowing the test to
detect missing per-payload pattern resets.

Wait for the receiver and propagate verification failures. Bound
both processes with timeouts and leave the existing benchmarks
unchanged.

Signed-off-by: shuo huang <f64116045@xxxxxxxxxxxxxx>
---
tools/testing/selftests/net/udpgso_bench.sh | 34 +++++++++++++++++++++
1 file changed, 34 insertions(+)

diff --git a/tools/testing/selftests/net/udpgso_bench.sh b/tools/testing/selftests/net/udpgso_bench.sh
index 88fa1d53b..d02f206ec 100755
--- a/tools/testing/selftests/net/udpgso_bench.sh
+++ b/tools/testing/selftests/net/udpgso_bench.sh
@@ -8,6 +8,8 @@ readonly YELLOW='\033[0;33m'
readonly RED='\033[0;31m'
readonly NC='\033[0m' # No Color
readonly TESTPORT=8000
+# Avoid a multiple of 26 to detect missing payload resets.
+readonly TCP_VERIFY_LEN=$((4 * 1024))

readonly KSFT_PASS=0
readonly KSFT_FAIL=1
@@ -79,6 +81,31 @@ run_one() {
./udpgso_bench_tx -p "$TESTPORT" ${args}
}

+run_tcp_verify_one() {
+ local tcp_rx_pid
+ local i=0
+ local -r timeout=10
+
+ timeout -k 1 30 ./udpgso_bench_rx -p "$TESTPORT" -t -v -l "$TCP_VERIFY_LEN" &
+ tcp_rx_pid=$!
+
+ while [ "$i" -lt "$timeout" ]; do
+ ss -lnHt "sport = :$TESTPORT" | grep -q . && break
+ i=$((i + 1))
+ sleep 1
+ done
+ if [ "$i" -eq "$timeout" ]; then
+ echo "timed out while waiting for udpgso_bench_rx"
+ return 1
+ fi
+
+ timeout -k 1 30 ./udpgso_bench_tx -p "$TESTPORT" "$@" \
+ -t -s "$TCP_VERIFY_LEN" -M 100 || return $?
+
+ # A successful sender does not imply that payload verification passed.
+ wait "$tcp_rx_pid"
+}
+
run_in_netns() {
local -r args=$@

@@ -123,6 +150,10 @@ run_tcp() {
echo "tcp zerocopy"
run_in_netns ${args} -t -z

+ echo "tcp verify"
+ ./in_netns.sh "$0" __verify_tcp ${args}
+ kselftest_test_exitcode $?
+
# excluding for now because test fails intermittently
# add -P option to include poll() to reduce possibility of lost messages
#echo "tcp zerocopy audit"
@@ -149,6 +180,9 @@ if [[ $# -eq 0 ]]; then
elif [[ $1 == "__subprocess" ]]; then
shift
run_one $@
+elif [[ $1 == "__verify_tcp" ]]; then
+ shift
+ run_tcp_verify_one "$@"
else
run_in_netns $@
fi
--
2.34.1