diff mbox series

[net] selftests/net: big_tcp: make ipv6 testing optional

Message ID 20250217174908.1157168-1-pablmart@redhat.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] selftests/net: big_tcp: make ipv6 testing optional | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success Errors and warnings before: 26 (+1) this patch: 26 (+1)
netdev/cc_maintainers warning 1 maintainers not CCed: linux-kselftest@vger.kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff fail author Signed-off-by missing
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns WARNING: line length of 83 exceeds 80 columns WARNING: line length of 88 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Pablo Martin Medrano Feb. 17, 2025, 5:49 p.m. UTC
Allow to run this test where IPV6 has not been configured.
---
 tools/testing/selftests/net/big_tcp.sh | 42 +++++++++++++++++++-------
 1 file changed, 31 insertions(+), 11 deletions(-)

Comments

Jakub Kicinski Feb. 17, 2025, 11:04 p.m. UTC | #1
On Mon, 17 Feb 2025 18:49:08 +0100 Pablo Martin Medrano wrote:
> Allow to run this test where IPV6 has not been configured.

nit: You're missing a Signed-off-by tag.

I think this test was added prior to driver selftests.
A better move would be to migrate it to the Python wrappers,
see tools/testing/selftests/drivers/net/*.py

That way it's easier to run it against real HW automatically,
an in SW CI it will be run against netdevsim.
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/big_tcp.sh b/tools/testing/selftests/net/big_tcp.sh
index 2db9d15cd45f..476ad882c1bd 100755
--- a/tools/testing/selftests/net/big_tcp.sh
+++ b/tools/testing/selftests/net/big_tcp.sh
@@ -21,6 +21,8 @@  CLIENT_GW6="2001:db8:1::2"
 MAX_SIZE=128000
 CHK_SIZE=65535
 
+ipv6=true
+
 # Kselftest framework requirement - SKIP code is 4.
 ksft_skip=4
 
@@ -34,9 +36,9 @@  setup() {
 	ip -net $CLIENT_NS link set link0 up
 	ip -net $CLIENT_NS link set link0 mtu 1442
 	ip -net $CLIENT_NS addr add $CLIENT_IP4/24 dev link0
-	ip -net $CLIENT_NS addr add $CLIENT_IP6/64 dev link0 nodad
+	$ipv6 && ip -net $CLIENT_NS addr add $CLIENT_IP6/64 dev link0 nodad
 	ip -net $CLIENT_NS route add $SERVER_IP4 dev link0 via $CLIENT_GW4
-	ip -net $CLIENT_NS route add $SERVER_IP6 dev link0 via $CLIENT_GW6
+	$ipv6 && ip -net $CLIENT_NS route add $SERVER_IP6 dev link0 via $CLIENT_GW6
 	ip -net $CLIENT_NS link set dev link0 \
 		gro_ipv4_max_size $MAX_SIZE gso_ipv4_max_size $MAX_SIZE
 	ip -net $CLIENT_NS link set dev link0 \
@@ -46,9 +48,9 @@  setup() {
 	ip -net $ROUTER_NS link set link1 up
 	ip -net $ROUTER_NS link set link2 up
 	ip -net $ROUTER_NS addr add $CLIENT_GW4/24 dev link1
-	ip -net $ROUTER_NS addr add $CLIENT_GW6/64 dev link1 nodad
+	$ipv6 && ip -net $ROUTER_NS addr add $CLIENT_GW6/64 dev link1 nodad
 	ip -net $ROUTER_NS addr add $SERVER_GW4/24 dev link2
-	ip -net $ROUTER_NS addr add $SERVER_GW6/64 dev link2 nodad
+	$ipv6 && ip -net $ROUTER_NS addr add $SERVER_GW6/64 dev link2 nodad
 	ip -net $ROUTER_NS link set dev link1 \
 		gro_ipv4_max_size $MAX_SIZE gso_ipv4_max_size $MAX_SIZE
 	ip -net $ROUTER_NS link set dev link2 \
@@ -61,16 +63,16 @@  setup() {
 	ip net exec $ROUTER_NS tc qdisc add dev link1 ingress
 	ip net exec $ROUTER_NS tc filter add dev link1 ingress \
 		proto ip flower ip_proto tcp action ct
-	ip net exec $ROUTER_NS tc filter add dev link1 ingress \
-		proto ipv6 flower ip_proto tcp action ct
+	$ipv6 && ip net exec $ROUTER_NS tc filter add dev link1 ingress \
+			proto ipv6 flower ip_proto tcp action ct
 	ip net exec $ROUTER_NS sysctl -wq net.ipv4.ip_forward=1
-	ip net exec $ROUTER_NS sysctl -wq net.ipv6.conf.all.forwarding=1
+	$ipv6 && ip net exec $ROUTER_NS sysctl -wq net.ipv6.conf.all.forwarding=1
 
 	ip -net $SERVER_NS link set link3 up
 	ip -net $SERVER_NS addr add $SERVER_IP4/24 dev link3
-	ip -net $SERVER_NS addr add $SERVER_IP6/64 dev link3 nodad
+	$ipv6 && ip -net $SERVER_NS addr add $SERVER_IP6/64 dev link3 nodad
 	ip -net $SERVER_NS route add $CLIENT_IP4 dev link3 via $SERVER_GW4
-	ip -net $SERVER_NS route add $CLIENT_IP6 dev link3 via $SERVER_GW6
+	$ipv6 && ip -net $SERVER_NS route add $CLIENT_IP6 dev link3 via $SERVER_GW6
 	ip -net $SERVER_NS link set dev link3 \
 		gro_ipv4_max_size $MAX_SIZE gso_ipv4_max_size $MAX_SIZE
 	ip -net $SERVER_NS link set dev link3 \
@@ -165,6 +167,24 @@  testup() {
 	do_test "off" "on"  "off" "on"
 }
 
+usage() {
+	echo "Usage: $0 [ -4 ]"
+	echo -e "\t-4: IPv4 only: disable IPv6 tests (default: test both IPv4 and IPv6)"
+}
+
+optstring="h4"
+while getopts "$optstring" option;do
+	case "$option" in
+	"h")
+		usage $0
+		exit ${KSFT_PASS}
+		;;
+	"4")
+		ipv6=false
+		;;
+	esac
+done
+
 if ! netperf -V &> /dev/null; then
 	echo "SKIP: Could not run test without netperf tool"
 	exit $ksft_skip
@@ -177,6 +197,6 @@  fi
 
 trap cleanup EXIT
 setup && echo "Testing for BIG TCP:" && \
-NF=4 testup && echo "***v4 Tests Done***" && \
-NF=6 testup && echo "***v6 Tests Done***"
+NF=4 testup && echo "***v4 Tests Done***" || exit $?
+$ipv6 && NF=6 testup && echo "***v6 Tests Done***"
 exit $?