Patch "selftests: mptcp: join: skip test if iptables/tc cmds fail" has been added to the 6.3-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    selftests: mptcp: join: skip test if iptables/tc cmds fail

to the 6.3-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     selftests-mptcp-join-skip-test-if-iptables-tc-cmds-fail.patch
and it can be found in the queue-6.3 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From 4a0b866a3f7d3c22033f40e93e94befc6fe51bce Mon Sep 17 00:00:00 2001
From: Matthieu Baerts <matthieu.baerts@xxxxxxxxxxxx>
Date: Sat, 10 Jun 2023 18:11:40 +0200
Subject: selftests: mptcp: join: skip test if iptables/tc cmds fail

From: Matthieu Baerts <matthieu.baerts@xxxxxxxxxxxx>

commit 4a0b866a3f7d3c22033f40e93e94befc6fe51bce upstream.

Selftests are supposed to run on any kernels, including the old ones not
supporting all MPTCP features.

Some tests are using IPTables and/or TC commands to force some
behaviours. If one of these commands fails -- likely because some
features are not available due to missing kernel config -- we should
intercept the error and skip the tests requiring these features.

Note that if we expect to have these features available and if
SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var is set to 1, the tests
will be marked as failed instead of skipped.

This patch also replaces the 'exit 1' by 'return 1' not to stop the
selftest in the middle without the conclusion if there is an issue with
NF or TC.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368
Fixes: 8d014eaa9254 ("selftests: mptcp: add ADD_ADDR timeout test case")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Matthieu Baerts <matthieu.baerts@xxxxxxxxxxxx>
Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh |   88 +++++++++++++++---------
 1 file changed, 57 insertions(+), 31 deletions(-)

--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -286,11 +286,15 @@ reset_with_add_addr_timeout()
 	fi
 
 	ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
-	ip netns exec $ns2 $tables -A OUTPUT -p tcp \
-		-m tcp --tcp-option 30 \
-		-m bpf --bytecode \
-		"$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \
-		-j DROP
+
+	if ! ip netns exec $ns2 $tables -A OUTPUT -p tcp \
+			-m tcp --tcp-option 30 \
+			-m bpf --bytecode \
+			"$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \
+			-j DROP; then
+		mark_as_skipped "unable to set the 'add addr' rule"
+		return 1
+	fi
 }
 
 # $1: test name
@@ -334,17 +338,12 @@ reset_with_allow_join_id0()
 #     tc action pedit offset 162 out of bounds
 #
 # Netfilter is used to mark packets with enough data.
-reset_with_fail()
+setup_fail_rules()
 {
-	reset "${1}" || return 1
-
-	ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=1
-	ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=1
-
 	check_invert=1
 	validate_checksum=1
-	local i="$2"
-	local ip="${3:-4}"
+	local i="$1"
+	local ip="${2:-4}"
 	local tables
 
 	tables="${iptables}"
@@ -359,15 +358,32 @@ reset_with_fail()
 		-p tcp \
 		-m length --length 150:9999 \
 		-m statistic --mode nth --packet 1 --every 99999 \
-		-j MARK --set-mark 42 || exit 1
+		-j MARK --set-mark 42 || return ${ksft_skip}
 
-	tc -n $ns2 qdisc add dev ns2eth$i clsact || exit 1
+	tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${ksft_skip}
 	tc -n $ns2 filter add dev ns2eth$i egress \
 		protocol ip prio 1000 \
 		handle 42 fw \
 		action pedit munge offset 148 u8 invert \
 		pipe csum tcp \
-		index 100 || exit 1
+		index 100 || return ${ksft_skip}
+}
+
+reset_with_fail()
+{
+	reset "${1}" || return 1
+	shift
+
+	ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=1
+	ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=1
+
+	local rc=0
+	setup_fail_rules "${@}" || rc=$?
+
+	if [ ${rc} -eq ${ksft_skip} ]; then
+		mark_as_skipped "unable to set the 'fail' rules"
+		return 1
+	fi
 }
 
 reset_with_events()
@@ -382,6 +398,25 @@ reset_with_events()
 	evts_ns2_pid=$!
 }
 
+reset_with_tcp_filter()
+{
+	reset "${1}" || return 1
+	shift
+
+	local ns="${!1}"
+	local src="${2}"
+	local target="${3}"
+
+	if ! ip netns exec "${ns}" ${iptables} \
+			-A INPUT \
+			-s "${src}" \
+			-p tcp \
+			-j "${target}"; then
+		mark_as_skipped "unable to set the filter rules"
+		return 1
+	fi
+}
+
 fail_test()
 {
 	ret=1
@@ -745,15 +780,6 @@ pm_nl_check_endpoint()
 	fi
 }
 
-filter_tcp_from()
-{
-	local ns="${1}"
-	local src="${2}"
-	local target="${3}"
-
-	ip netns exec "${ns}" ${iptables} -A INPUT -s "${src}" -p tcp -j "${target}"
-}
-
 do_transfer()
 {
 	local listener_ns="$1"
@@ -1935,23 +1961,23 @@ subflows_error_tests()
 	fi
 
 	# multiple subflows, with subflow creation error
-	if reset "multi subflows, with failing subflow"; then
+	if reset_with_tcp_filter "multi subflows, with failing subflow" ns1 10.0.3.2 REJECT &&
+	   continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then
 		pm_nl_set_limits $ns1 0 2
 		pm_nl_set_limits $ns2 0 2
 		pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
 		pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
-		filter_tcp_from $ns1 10.0.3.2 REJECT
 		run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
 		chk_join_nr 1 1 1
 	fi
 
 	# multiple subflows, with subflow timeout on MPJ
-	if reset "multi subflows, with subflow timeout"; then
+	if reset_with_tcp_filter "multi subflows, with subflow timeout" ns1 10.0.3.2 DROP &&
+	   continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then
 		pm_nl_set_limits $ns1 0 2
 		pm_nl_set_limits $ns2 0 2
 		pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
 		pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow
-		filter_tcp_from $ns1 10.0.3.2 DROP
 		run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow
 		chk_join_nr 1 1 1
 	fi
@@ -1959,11 +1985,11 @@ subflows_error_tests()
 	# multiple subflows, check that the endpoint corresponding to
 	# closed subflow (due to reset) is not reused if additional
 	# subflows are added later
-	if reset "multi subflows, fair usage on close"; then
+	if reset_with_tcp_filter "multi subflows, fair usage on close" ns1 10.0.3.2 REJECT &&
+	   continue_if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then
 		pm_nl_set_limits $ns1 0 1
 		pm_nl_set_limits $ns2 0 1
 		pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow
-		filter_tcp_from $ns1 10.0.3.2 REJECT
 		run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow &
 
 		# mpj subflow will be in TW after the reset


Patches currently in stable-queue which might be from matthieu.baerts@xxxxxxxxxxxx are

queue-6.3/selftests-mptcp-join-fix-shellcheck-warnings.patch
queue-6.3/selftests-mptcp-join-support-rm_addr-for-used-endpoints-or-not.patch
queue-6.3/selftests-mptcp-pm-nl-skip-fullmesh-flag-checks-if-not-supported.patch
queue-6.3/selftests-mptcp-lib-skip-if-missing-symbol.patch
queue-6.3/selftests-mptcp-join-skip-fullmesh-flag-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-connect-skip-tfo-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-join-skip-fastclose-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-remove-duplicated-entries-in-usage.patch
queue-6.3/selftests-mptcp-sockopt-skip-getsockopt-checks-if-not-supported.patch
queue-6.3/selftests-mptcp-join-skip-backup-if-set-flag-on-id-not-supported.patch
queue-6.3/selftests-mptcp-join-skip-mixed-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-userspace-pm-skip-if-ip-tool-is-unavailable.patch
queue-6.3/selftests-mptcp-join-helpers-to-skip-tests.patch
queue-6.3/selftests-mptcp-lib-skip-if-not-below-kernel-version.patch
queue-6.3/selftests-mptcp-userspace-pm-skip-if-not-supported.patch
queue-6.3/selftests-mptcp-join-uniform-listener-tests.patch
queue-6.3/selftests-mptcp-diag-skip-listen-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-sockopt-skip-tcp_inq-checks-if-not-supported.patch
queue-6.3/selftests-mptcp-join-skip-test-if-iptables-tc-cmds-fail.patch
queue-6.3/selftests-mptcp-join-skip-implicit-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-userspace-pm-skip-pm-listener-events-tests-if-unavailable.patch
queue-6.3/selftests-mptcp-join-skip-fail-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-sockopt-relax-expected-returned-size.patch
queue-6.3/selftests-mptcp-pm-nl-remove-hardcoded-default-limits.patch
queue-6.3/selftests-mptcp-join-skip-check-if-mib-counter-not-supported.patch
queue-6.3/selftests-mptcp-diag-skip-inuse-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-join-use-iptables-legacy-if-available.patch
queue-6.3/selftests-mptcp-join-support-local-endpoint-being-tracked-or-not.patch
queue-6.3/selftests-mptcp-join-skip-userspace-pm-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-connect-skip-transp-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-join-skip-mpc-backups-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-join-skip-pm-listener-tests-if-not-supported.patch
queue-6.3/selftests-mptcp-connect-skip-disconnect-tests-if-not-supported.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux