Skip to content

Commit 496bc58

Browse files
Florian Westphalkuba-moo
authored andcommitted
selftests: netfilter: nft_concat_range.sh: reduce debug kernel run time
Even a 1h timeout isn't enough for nft_concat_range.sh to complete on debug kernels. Reduce test complexity and only match on single entry if KSFT_MACHINE_SLOW is set. To spot 'slow' tests, print the subtest duration (in seconds) in addition to the status. Add new nft_concat_range_perf.sh script, not executed via kselftest, to run the performance (pps match rate) tests. Those need about 25m to complete which seems too much to run this via 'make run_tests'. Signed-off-by: Florian Westphal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fff6e6a commit 496bc58

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

tools/testing/selftests/net/netfilter/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ TEST_PROGS += nft_zones_many.sh
2828
TEST_PROGS += rpath.sh
2929
TEST_PROGS += xt_string.sh
3030

31+
TEST_PROGS_EXTENDED = nft_concat_range_perf.sh
32+
3133
TEST_GEN_PROGS = conntrack_dump_flush
3234

3335
TEST_GEN_FILES = audit_logread

tools/testing/selftests/net/netfilter/config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ CONFIG_VETH=m
8585
CONFIG_VLAN_8021Q=m
8686
CONFIG_XFRM_USER=m
8787
CONFIG_XFRM_STATISTICS=y
88+
CONFIG_NET_PKTGEN=m

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ source lib.sh
1919
# - timeout: check that packets match entries until they expire
2020
# - performance: estimate matching rate, compare with rbtree and hash baselines
2121
TESTS="reported_issues correctness concurrency timeout"
22-
[ "${quicktest}" != "1" ] && TESTS="${TESTS} performance"
22+
[ -n "$NFT_CONCAT_RANGE_TESTS" ] && TESTS="${NFT_CONCAT_RANGE_TESTS}"
2323

2424
# Set types, defined by TYPE_ variables below
2525
TYPES="net_port port_net net6_port port_proto net6_port_mac net6_port_mac_proto
@@ -31,7 +31,7 @@ BUGS="flush_remove_add reload"
3131

3232
# List of possible paths to pktgen script from kernel tree for performance tests
3333
PKTGEN_SCRIPT_PATHS="
34-
../../../../samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh
34+
../../../../../samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh
3535
pktgen/pktgen_bench_xmit_mode_netif_receive.sh"
3636

3737
# Definition of set types:
@@ -951,6 +951,10 @@ cleanup() {
951951
killall iperf 2>/dev/null
952952
killall netperf 2>/dev/null
953953
killall netserver 2>/dev/null
954+
}
955+
956+
cleanup_exit() {
957+
cleanup
954958
rm -f "$tmp"
955959
}
956960

@@ -1371,6 +1375,9 @@ test_timeout() {
13711375
setup veth send_"${proto}" set || return ${ksft_skip}
13721376

13731377
timeout=3
1378+
1379+
[ "$KSFT_MACHINE_SLOW" = "yes" ] && timeout=8
1380+
13741381
range_size=1
13751382
for i in $(seq "$start" $((start + count))); do
13761383
end=$((start + range_size))
@@ -1386,7 +1393,7 @@ test_timeout() {
13861393
range_size=$((range_size + 1))
13871394
start=$((end + range_size))
13881395
done
1389-
sleep 3
1396+
sleep $timeout
13901397
for i in $(seq "$start" $((start + count))); do
13911398
end=$((start + range_size))
13921399
srcstart=$((start + src_delta))
@@ -1480,10 +1487,13 @@ test_performance() {
14801487
}
14811488

14821489
test_bug_flush_remove_add() {
1490+
rounds=100
1491+
[ "$KSFT_MACHINE_SLOW" = "yes" ] && rounds=10
1492+
14831493
set_cmd='{ set s { type ipv4_addr . inet_service; flags interval; }; }'
14841494
elem1='{ 10.0.0.1 . 22-25, 10.0.0.1 . 10-20 }'
14851495
elem2='{ 10.0.0.1 . 10-20, 10.0.0.1 . 22-25 }'
1486-
for i in $(seq 1 100); do
1496+
for i in $(seq 1 $rounds); do
14871497
nft add table t "$set_cmd" || return ${ksft_skip}
14881498
nft add element t s "$elem1" 2>/dev/null || return 1
14891499
nft flush set t s 2>/dev/null || return 1
@@ -1552,7 +1562,7 @@ test_reported_issues() {
15521562
# Run everything in a separate network namespace
15531563
[ "${1}" != "run" ] && { unshare -n "${0}" run; exit $?; }
15541564
tmp="$(mktemp)"
1555-
trap cleanup EXIT
1565+
trap cleanup_exit EXIT
15561566

15571567
# Entry point for test runs
15581568
passed=0
@@ -1584,10 +1594,16 @@ for name in ${TESTS}; do
15841594
continue
15851595
fi
15861596

1587-
printf " %-60s " "${display}"
1597+
[ "$KSFT_MACHINE_SLOW" = "yes" ] && count=1
1598+
1599+
printf " %-32s " "${display}"
1600+
tthen=$(date +%s)
15881601
eval test_"${name}"
15891602
ret=$?
15901603

1604+
tnow=$(date +%s)
1605+
printf "%5ds%-30s" $((tnow-tthen))
1606+
15911607
if [ $ret -eq 0 ]; then
15921608
printf "[ OK ]\n"
15931609
info_flush
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
5+
source lib.sh
6+
7+
[ "$KSFT_MACHINE_SLOW" = yes ] && exit ${ksft_skip}
8+
9+
NFT_CONCAT_RANGE_TESTS="performance" exec ./nft_concat_range.sh

0 commit comments

Comments
 (0)