Skip to content

Commit 0632c52

Browse files
committed
Merge: netfilter: selftests: stable backport for 10.1 phase 2
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1097 JIRA: https://issues.redhat.com/browse/RHEL-99472 * df6cb25 selftests: netfilter: Add missing gitignore file * fc49b80 selftests: netfilter: run conntrack_dump_flush in netns * a84e8c0 selftests: netfilter: nft_queue.sh: fix warnings with socat 1.8.0.0 * 429d410 selftests: netfilter: nft_queue.sh: include file transfer duration in log message Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> --- <small>Created 2025-06-24 09:41 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12334433&issuetype=1&priority=4&summary=backporter+webhook+issue&components=kernel-workflow+/+backporter)</small> Approved-by: Phil Sutter <psutter@redhat.com> Approved-by: Hangbin Liu <haliu@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents 7f6c4e2 + ec00ec8 commit 0632c52

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

tools/testing/selftests/net/netfilter/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
audit_logread
33
connect_close
44
conntrack_dump_flush
5+
conntrack_reverse_clash
56
sctp_collision
67
nf_queue

tools/testing/selftests/net/netfilter/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ MNL_LDLIBS := $(shell $(HOSTPKG_CONFIG) --libs libmnl 2>/dev/null || echo -lmnl)
88

99
TEST_PROGS := br_netfilter.sh bridge_brouter.sh
1010
TEST_PROGS += br_netfilter_queue.sh
11+
TEST_PROGS += conntrack_dump_flush.sh
1112
TEST_PROGS += conntrack_icmp_related.sh
1213
TEST_PROGS += conntrack_ipip_mtu.sh
1314
TEST_PROGS += conntrack_tcp_unreplied.sh
@@ -37,10 +38,9 @@ TEST_PROGS += xt_string.sh
3738

3839
TEST_PROGS_EXTENDED = nft_concat_range_perf.sh
3940

40-
TEST_GEN_PROGS = conntrack_dump_flush
41-
4241
TEST_GEN_FILES = audit_logread
4342
TEST_GEN_FILES += connect_close nf_queue
43+
TEST_GEN_FILES += conntrack_dump_flush
4444
TEST_GEN_FILES += conntrack_reverse_clash
4545
TEST_GEN_FILES += sctp_collision
4646

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
exec unshare -n ./conntrack_dump_flush

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

Lines changed: 35 additions & 11 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"
@@ -512,10 +536,10 @@ EOF
512536
:> "$TMPFILE1"
513537
:> "$TMPFILE2"
514538

515-
timeout 10 ip netns exec "$ns2" socat UDP-LISTEN:12345,fork OPEN:"$TMPFILE1",trunc &
539+
timeout 10 ip netns exec "$ns2" socat UDP-LISTEN:12345,fork,pf=ipv4 OPEN:"$TMPFILE1",trunc &
516540
local rpid1=$!
517541

518-
timeout 10 ip netns exec "$ns3" socat UDP-LISTEN:12345,fork OPEN:"$TMPFILE2",trunc &
542+
timeout 10 ip netns exec "$ns3" socat UDP-LISTEN:12345,fork,pf=ipv4 OPEN:"$TMPFILE2",trunc &
519543
local rpid2=$!
520544

521545
ip netns exec "$nsrouter" ./nf_queue -q 12 -d 1000 &
@@ -528,8 +552,8 @@ EOF
528552
# Send two packets, one should end up in ns1, other in ns2.
529553
# This is because nfqueue will delay packet for long enough so that
530554
# second packet will not find existing conntrack entry.
531-
echo "Packet 1" | ip netns exec "$ns1" socat STDIN UDP-DATAGRAM:10.6.6.6:12345,bind=0.0.0.0:55221
532-
echo "Packet 2" | ip netns exec "$ns1" socat STDIN UDP-DATAGRAM:10.6.6.6:12345,bind=0.0.0.0:55221
555+
echo "Packet 1" | ip netns exec "$ns1" socat -u STDIN UDP-DATAGRAM:10.6.6.6:12345,bind=0.0.0.0:55221
556+
echo "Packet 2" | ip netns exec "$ns1" socat -u STDIN UDP-DATAGRAM:10.6.6.6:12345,bind=0.0.0.0:55221
533557

534558
busywait 10000 output_files_written "$TMPFILE1" "$TMPFILE2"
535559

0 commit comments

Comments
 (0)