* [PATCH net-next v3 0/2] selftests: net: Exercise TCP payload verification
@ 2026-09-14 0:45 shuo huang
2026-09-14 0:45 ` [PATCH net-next v3 1/2] selftests: net: Add TCP payload verification to udpgso_bench_rx shuo huang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: shuo huang @ 2026-09-14 0:45 UTC (permalink / raw)
To: netdev
Cc: linux-kselftest, linux-kernel, davem, edumazet, kuba, pabeni,
horms, shuah, jiayuan.chen, f64116045
This series adds TCP payload verification to udpgso_bench_rx and
exercises it from udpgso_bench.sh for both IPv4 and IPv6. The test
checks the receiver's exit status so that verification errors are
reported as test failures.
Changes since v2:
- Wrap the receiver command in patch 2 to stay within 80 columns.
v2: https://lore.kernel.org/r/20260911160649.51863-1-f64116045@gs.ncku.edu.tw
Changes since v1:
- Add patch 2 to exercise the TCP verifier from udpgso_bench.sh,
addressing Jakub's feedback.
v1: https://lore.kernel.org/r/20260906145643.219609-1-f64116045@gs.ncku.edu.tw
Testing (v2):
- udpgso_bench.sh: PASS=22 SKIP=0 FAIL=0.
No full kernel build or boot of a patched net-next kernel was performed.
shuo huang (2):
selftests: net: Add TCP payload verification to udpgso_bench_rx
selftests: net: Exercise TCP payload verification in udpgso_bench.sh
tools/testing/selftests/net/udpgso_bench.sh | 35 +++++++++++++
tools/testing/selftests/net/udpgso_bench_rx.c | 51 +++++++++++++++----
2 files changed, 77 insertions(+), 9 deletions(-)
base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v3 1/2] selftests: net: Add TCP payload verification to udpgso_bench_rx
2026-09-14 0:45 [PATCH net-next v3 0/2] selftests: net: Exercise TCP payload verification shuo huang
@ 2026-09-14 0:45 ` shuo huang
2026-09-14 0:45 ` [PATCH net-next v3 2/2] selftests: net: Exercise TCP payload verification in udpgso_bench.sh shuo huang
2026-09-17 9:37 ` [PATCH net-next v3 0/2] selftests: net: Exercise TCP payload verification Paolo Abeni
2 siblings, 0 replies; 4+ messages in thread
From: shuo huang @ 2026-09-14 0:45 UTC (permalink / raw)
To: netdev
Cc: linux-kselftest, linux-kernel, davem, edumazet, kuba, pabeni,
horms, shuah, jiayuan.chen, f64116045
udpgso_bench_rx supports UDP payload verification but rejects the
combination of TCP and verification mode. Its TCP receive path discards
the payload, so it cannot check the data generated by udpgso_bench_tx.
Read the TCP payload into a buffer when verification is requested
and check it against the transmitter's repeating alphabetic
pattern. Preserve the verification position across recv() calls
because TCP does not preserve send boundaries. Restart the pattern
at the payload length supplied with -l, matching the transmitter's
pattern restart on each message.
Require a nonzero -l value for TCP verification and retain the existing
discard path when verification is disabled.
Signed-off-by: shuo huang <f64116045@gs.ncku.edu.tw>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
tools/testing/selftests/net/udpgso_bench_rx.c | 51 +++++++++++++++----
1 file changed, 42 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/net/udpgso_bench_rx.c b/tools/testing/selftests/net/udpgso_bench_rx.c
index 1cbadd267..5270a46d2 100644
--- a/tools/testing/selftests/net/udpgso_bench_rx.c
+++ b/tools/testing/selftests/net/udpgso_bench_rx.c
@@ -89,6 +89,11 @@ static unsigned long gettimeofday_ms(void)
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
+static char expected_char(unsigned int off)
+{
+ return 'a' + (off % 26);
+}
+
static void do_poll(int fd, int timeout_ms)
{
struct pollfd pfd;
@@ -161,14 +166,44 @@ static int do_socket(bool do_tcp)
return fd;
}
+static char sanitized_char(char val)
+{
+ return (val >= 'a' && val <= 'z') ? val : '.';
+}
+
+static void do_verify_tcp(const char *data, int len)
+{
+ static unsigned int stream_off;
+ int i;
+
+ for (i = 0; i < len; i++) {
+ char expected = expected_char(stream_off);
+
+ if (data[i] != expected)
+ error(1, 0,
+ "data[%d]: stream offset %u, %c(%hhu) != %c(%hhu)\n",
+ i, stream_off,
+ sanitized_char(data[i]), data[i],
+ expected, expected);
+
+ stream_off++;
+ if (stream_off == cfg_expected_pkt_len)
+ stream_off = 0;
+ }
+}
+
/* Flush all outstanding bytes for the tcp receive queue */
static void do_flush_tcp(int fd)
{
+ static char rbuf[ETH_MAX_MTU];
int ret;
while (true) {
- /* MSG_TRUNC flushes up to len bytes */
- ret = recv(fd, NULL, 1 << 21, MSG_TRUNC | MSG_DONTWAIT);
+ if (cfg_verify)
+ ret = recv(fd, rbuf, sizeof(rbuf), MSG_DONTWAIT);
+ else
+ /* MSG_TRUNC flushes up to len bytes */
+ ret = recv(fd, NULL, 1 << 21, MSG_TRUNC | MSG_DONTWAIT);
if (ret == -1 && errno == EAGAIN)
return;
if (ret == -1)
@@ -178,17 +213,15 @@ static void do_flush_tcp(int fd)
exit(0);
}
+ if (cfg_verify)
+ do_verify_tcp(rbuf, ret);
+
packets++;
bytes += ret;
}
}
-static char sanitized_char(char val)
-{
- return (val >= 'a' && val <= 'z') ? val : '.';
-}
-
static void do_verify_udp(const char *data, int len)
{
char cur = data[0];
@@ -347,8 +380,8 @@ static void parse_opts(int argc, char **argv)
if (optind != argc)
usage(argv[0]);
- if (cfg_tcp && cfg_verify)
- error(1, 0, "TODO: implement verify mode for tcp");
+ if (cfg_tcp && cfg_verify && !cfg_expected_pkt_len)
+ error(1, 0, "tcp verify mode requires -l");
}
static void do_recv(void)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next v3 2/2] selftests: net: Exercise TCP payload verification in udpgso_bench.sh
2026-09-14 0:45 [PATCH net-next v3 0/2] selftests: net: Exercise TCP payload verification shuo huang
2026-09-14 0:45 ` [PATCH net-next v3 1/2] selftests: net: Add TCP payload verification to udpgso_bench_rx shuo huang
@ 2026-09-14 0:45 ` shuo huang
2026-09-17 9:37 ` [PATCH net-next v3 0/2] selftests: net: Exercise TCP payload verification Paolo Abeni
2 siblings, 0 replies; 4+ messages in thread
From: shuo huang @ 2026-09-14 0:45 UTC (permalink / raw)
To: netdev
Cc: linux-kselftest, linux-kernel, davem, edumazet, kuba, pabeni,
horms, shuah, jiayuan.chen, f64116045
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@gs.ncku.edu.tw>
---
tools/testing/selftests/net/udpgso_bench.sh | 35 +++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/tools/testing/selftests/net/udpgso_bench.sh b/tools/testing/selftests/net/udpgso_bench.sh
index 88fa1d53b..4d1938282 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,32 @@ 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 +151,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 +181,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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v3 0/2] selftests: net: Exercise TCP payload verification
2026-09-14 0:45 [PATCH net-next v3 0/2] selftests: net: Exercise TCP payload verification shuo huang
2026-09-14 0:45 ` [PATCH net-next v3 1/2] selftests: net: Add TCP payload verification to udpgso_bench_rx shuo huang
2026-09-14 0:45 ` [PATCH net-next v3 2/2] selftests: net: Exercise TCP payload verification in udpgso_bench.sh shuo huang
@ 2026-09-17 9:37 ` Paolo Abeni
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Abeni @ 2026-09-17 9:37 UTC (permalink / raw)
To: shuo huang, netdev
Cc: linux-kselftest, linux-kernel, davem, edumazet, kuba, horms,
shuah, jiayuan.chen
On 9/14/26 02:45, shuo huang wrote:
> This series adds TCP payload verification to udpgso_bench_rx and
> exercises it from udpgso_bench.sh for both IPv4 and IPv6. The test
> checks the receiver's exit status so that verification errors are
> reported as test failures.
>
> Changes since v2:
> - Wrap the receiver command in patch 2 to stay within 80 columns.
>
> v2: https://lore.kernel.org/r/20260911160649.51863-1-f64116045@gs.ncku.edu.tw
>
> Changes since v1:
> - Add patch 2 to exercise the TCP verifier from udpgso_bench.sh,
> addressing Jakub's feedback.
I think you did not answer the more fundamental question there: why is
this useful? I don't see much value on top of the existing GRO (h/w)
tests, while this add a bunch of testscase/runtime/resource usage on the
CI from now on.
In the current format it's IMHO not worth merging.
/P
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-17 9:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-14 0:45 [PATCH net-next v3 0/2] selftests: net: Exercise TCP payload verification shuo huang
2026-09-14 0:45 ` [PATCH net-next v3 1/2] selftests: net: Add TCP payload verification to udpgso_bench_rx shuo huang
2026-09-14 0:45 ` [PATCH net-next v3 2/2] selftests: net: Exercise TCP payload verification in udpgso_bench.sh shuo huang
2026-09-17 9:37 ` [PATCH net-next v3 0/2] selftests: net: Exercise TCP payload verification Paolo Abeni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox