Skip to content

Commit 429d410

Browse files
Florian Westphalkuba-moo
authored andcommitted
selftests: netfilter: nft_queue.sh: include file transfer duration in log message
Paolo Abeni says: Recently the nipa CI infra went through some tuning, and the mentioned self-test now often fails. The failing test is the sctp+nfqueue one, where the file transfer takes too long and hits the timeout (1 minute). Because SCTP nfqueue tests had timeout related issues before (esp. on debug kernels) print the file transfer duration in the PASS/FAIL message. This would aallow us to see if there is/was an unexpected slowdown (CI keeps logs around) or 'creeping slowdown' where things got slower over time until 'fail point' was reached. Output of altered lines looks like this: PASS: tcp and nfqueue in forward chan (duration: 2s) PASS: tcp via loopback (duration: 2s) PASS: sctp and nfqueue in forward chain (duration: 42s) PASS: sctp and nfqueue in output chain with GSO (duration: 21s) Reported-by: Paolo Abeni <[email protected] Closes: https://lore.kernel.org/netdev/[email protected]/ Signed-off-by: Florian Westphal <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 33f1b36 commit 429d410

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

tools/testing/selftests/net/netfilter/nft_queue.sh

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ source lib.sh
1010
ret=0
1111
timeout=5
1212

13+
SCTP_TEST_TIMEOUT=60
14+
1315
cleanup()
1416
{
1517
ip netns pids "$ns1" | xargs kill 2>/dev/null
@@ -40,7 +42,7 @@ TMPFILE3=$(mktemp)
4042

4143
TMPINPUT=$(mktemp)
4244
COUNT=200
43-
[ "$KSFT_MACHINE_SLOW" = "yes" ] && COUNT=25
45+
[ "$KSFT_MACHINE_SLOW" = "yes" ] && COUNT=$((COUNT/8))
4446
dd conv=sparse status=none if=/dev/zero bs=1M count=$COUNT of="$TMPINPUT"
4547

4648
if ! ip link add veth0 netns "$nsrouter" type veth peer name eth0 netns "$ns1" > /dev/null 2>&1; then
@@ -275,9 +277,11 @@ test_tcp_forward()
275277
busywait "$BUSYWAIT_TIMEOUT" listener_ready "$ns2"
276278
busywait "$BUSYWAIT_TIMEOUT" nf_queue_wait "$nsrouter" 2
277279

280+
local tthen=$(date +%s)
281+
278282
ip netns exec "$ns1" socat -u STDIN TCP:10.0.2.99:12345 <"$TMPINPUT" >/dev/null
279283

280-
wait "$rpid" && echo "PASS: tcp and nfqueue in forward chain"
284+
wait_and_check_retval "$rpid" "tcp and nfqueue in forward chain" "$tthen"
281285
kill "$nfqpid"
282286
}
283287

@@ -288,13 +292,14 @@ test_tcp_localhost()
288292

289293
ip netns exec "$nsrouter" ./nf_queue -q 3 &
290294
local nfqpid=$!
295+
local tthen=$(date +%s)
291296

292297
busywait "$BUSYWAIT_TIMEOUT" listener_ready "$nsrouter"
293298
busywait "$BUSYWAIT_TIMEOUT" nf_queue_wait "$nsrouter" 3
294299

295300
ip netns exec "$nsrouter" socat -u STDIN TCP:127.0.0.1:12345 <"$TMPINPUT" >/dev/null
296301

297-
wait "$rpid" && echo "PASS: tcp via loopback"
302+
wait_and_check_retval "$rpid" "tcp via loopback" "$tthen"
298303
kill "$nfqpid"
299304
}
300305

@@ -417,6 +422,23 @@ check_output_files()
417422
fi
418423
}
419424

425+
wait_and_check_retval()
426+
{
427+
local rpid="$1"
428+
local msg="$2"
429+
local tthen="$3"
430+
local tnow=$(date +%s)
431+
432+
if wait "$rpid";then
433+
echo -n "PASS: "
434+
else
435+
echo -n "FAIL: "
436+
ret=1
437+
fi
438+
439+
printf "%s (duration: %ds)\n" "$msg" $((tnow-tthen))
440+
}
441+
420442
test_sctp_forward()
421443
{
422444
ip netns exec "$nsrouter" nft -f /dev/stdin <<EOF
@@ -428,13 +450,14 @@ table inet sctpq {
428450
}
429451
}
430452
EOF
431-
timeout 60 ip netns exec "$ns2" socat -u SCTP-LISTEN:12345 STDOUT > "$TMPFILE1" &
453+
timeout "$SCTP_TEST_TIMEOUT" ip netns exec "$ns2" socat -u SCTP-LISTEN:12345 STDOUT > "$TMPFILE1" &
432454
local rpid=$!
433455

434456
busywait "$BUSYWAIT_TIMEOUT" sctp_listener_ready "$ns2"
435457

436458
ip netns exec "$nsrouter" ./nf_queue -q 10 -G &
437459
local nfqpid=$!
460+
local tthen=$(date +%s)
438461

439462
ip netns exec "$ns1" socat -u STDIN SCTP:10.0.2.99:12345 <"$TMPINPUT" >/dev/null
440463

@@ -443,7 +466,7 @@ EOF
443466
exit 1
444467
fi
445468

446-
wait "$rpid" && echo "PASS: sctp and nfqueue in forward chain"
469+
wait_and_check_retval "$rpid" "sctp and nfqueue in forward chain" "$tthen"
447470
kill "$nfqpid"
448471

449472
check_output_files "$TMPINPUT" "$TMPFILE1" "sctp forward"
@@ -462,13 +485,14 @@ EOF
462485
# reduce test file size, software segmentation causes sk wmem increase.
463486
dd conv=sparse status=none if=/dev/zero bs=1M count=$((COUNT/2)) of="$TMPINPUT"
464487

465-
timeout 60 ip netns exec "$ns2" socat -u SCTP-LISTEN:12345 STDOUT > "$TMPFILE1" &
488+
timeout "$SCTP_TEST_TIMEOUT" ip netns exec "$ns2" socat -u SCTP-LISTEN:12345 STDOUT > "$TMPFILE1" &
466489
local rpid=$!
467490

468491
busywait "$BUSYWAIT_TIMEOUT" sctp_listener_ready "$ns2"
469492

470493
ip netns exec "$ns1" ./nf_queue -q 11 &
471494
local nfqpid=$!
495+
local tthen=$(date +%s)
472496

473497
ip netns exec "$ns1" socat -u STDIN SCTP:10.0.2.99:12345 <"$TMPINPUT" >/dev/null
474498

@@ -478,7 +502,7 @@ EOF
478502
fi
479503

480504
# must wait before checking completeness of output file.
481-
wait "$rpid" && echo "PASS: sctp and nfqueue in output chain with GSO"
505+
wait_and_check_retval "$rpid" "sctp and nfqueue in output chain with GSO" "$tthen"
482506
kill "$nfqpid"
483507

484508
check_output_files "$TMPINPUT" "$TMPFILE1" "sctp output"

0 commit comments

Comments
 (0)