From: Greg Kroah-Hartman Date: Thu, 22 Jun 2023 08:07:18 +0000 (+0200) Subject: 6.1-stable patches X-Git-Tag: v4.14.320~60 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d21536b9c18f73854c9345ef7cc28c8f26e9305d;p=thirdparty%2Fkernel%2Fstable-queue.git 6.1-stable patches added patches: selftests-mptcp-connect-skip-disconnect-tests-if-not-supported.patch selftests-mptcp-connect-skip-transp-tests-if-not-supported.patch selftests-mptcp-join-fix-shellcheck-warnings.patch selftests-mptcp-join-helpers-to-skip-tests.patch selftests-mptcp-join-skip-backup-if-set-flag-on-id-not-supported.patch selftests-mptcp-join-skip-check-if-mib-counter-not-supported.patch selftests-mptcp-join-skip-fastclose-tests-if-not-supported.patch selftests-mptcp-join-skip-fullmesh-flag-tests-if-not-supported.patch selftests-mptcp-join-skip-implicit-tests-if-not-supported.patch selftests-mptcp-join-skip-mpc-backups-tests-if-not-supported.patch selftests-mptcp-join-support-local-endpoint-being-tracked-or-not.patch selftests-mptcp-join-support-rm_addr-for-used-endpoints-or-not.patch selftests-mptcp-join-use-iptables-legacy-if-available.patch selftests-mptcp-lib-skip-if-missing-symbol.patch selftests-mptcp-lib-skip-if-not-below-kernel-version.patch selftests-mptcp-pm-nl-remove-hardcoded-default-limits.patch selftests-mptcp-pm-nl-skip-fullmesh-flag-checks-if-not-supported.patch selftests-mptcp-remove-duplicated-entries-in-usage.patch selftests-mptcp-sockopt-relax-expected-returned-size.patch selftests-mptcp-sockopt-skip-getsockopt-checks-if-not-supported.patch selftests-mptcp-userspace-pm-skip-if-ip-tool-is-unavailable.patch selftests-mptcp-userspace-pm-skip-if-not-supported.patch --- diff --git a/queue-6.1/selftests-mptcp-connect-skip-disconnect-tests-if-not-supported.patch b/queue-6.1/selftests-mptcp-connect-skip-disconnect-tests-if-not-supported.patch new file mode 100644 index 00000000000..7537d0ac0ff --- /dev/null +++ b/queue-6.1/selftests-mptcp-connect-skip-disconnect-tests-if-not-supported.patch @@ -0,0 +1,44 @@ +From 4ad39a42da2e9770c8e4c37fe632ed8898419129 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:45 +0200 +Subject: selftests: mptcp: connect: skip disconnect tests if not supported + +From: Matthieu Baerts + +commit 4ad39a42da2e9770c8e4c37fe632ed8898419129 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the full support of disconnections from the userspace +introduced by commit b29fcfb54cd7 ("mptcp: full disconnect +implementation"). + +It is possible to look for "mptcp_pm_data_reset" in kallsyms because a +preparation patch added it to ease the introduction of the mentioned +feature. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 05be5e273c84 ("selftests: mptcp: add disconnect tests") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_connect.sh | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh +@@ -782,6 +782,11 @@ run_tests_disconnect() + local old_cin=$cin + local old_sin=$sin + ++ if ! mptcp_lib_kallsyms_has "mptcp_pm_data_reset$"; then ++ echo "INFO: Full disconnect not supported: SKIP" ++ return ++ fi ++ + cat $cin $cin $cin > "$cin".disconnect + + # force do_transfer to cope with the multiple tranmissions diff --git a/queue-6.1/selftests-mptcp-connect-skip-transp-tests-if-not-supported.patch b/queue-6.1/selftests-mptcp-connect-skip-transp-tests-if-not-supported.patch new file mode 100644 index 00000000000..01bd8c8ed02 --- /dev/null +++ b/queue-6.1/selftests-mptcp-connect-skip-transp-tests-if-not-supported.patch @@ -0,0 +1,58 @@ +From 07bf49401909264a38fa3427c3cce43e8304436a Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:44 +0200 +Subject: selftests: mptcp: connect: skip transp tests if not supported + +From: Matthieu Baerts + +commit 07bf49401909264a38fa3427c3cce43e8304436a upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the support of IP(V6)_TRANSPARENT socket option with +MPTCP connections introduced by commit c9406a23c116 ("mptcp: sockopt: +add SOL_IP freebind & transparent options"). + +It is possible to look for "__ip_sock_set_tos" in kallsyms because +IP(V6)_TRANSPARENT socket option support has been added after TOS +support which came with the required infrastructure in MPTCP sockopt +code. To support TOS, the following function has been exported (T). Not +great but better than checking for a specific kernel version. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 5fb62e9cd3ad ("selftests: mptcp: add tproxy test case") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_connect.sh | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh +@@ -144,6 +144,7 @@ cleanup() + } + + mptcp_lib_check_mptcp ++mptcp_lib_check_kallsyms + + ip -Version > /dev/null 2>&1 + if [ $? -ne 0 ];then +@@ -696,6 +697,15 @@ run_test_transparent() + return 0 + fi + ++ # IP(V6)_TRANSPARENT has been added after TOS support which came with ++ # the required infrastructure in MPTCP sockopt code. To support TOS, the ++ # following function has been exported (T). Not great but better than ++ # checking for a specific kernel version. ++ if ! mptcp_lib_kallsyms_has "T __ip_sock_set_tos$"; then ++ echo "INFO: ${msg} not supported by the kernel: SKIP" ++ return ++ fi ++ + ip netns exec "$listener_ns" nft -f /dev/stdin <<"EOF" + flush ruleset + table inet mangle { diff --git a/queue-6.1/selftests-mptcp-join-fix-shellcheck-warnings.patch b/queue-6.1/selftests-mptcp-join-fix-shellcheck-warnings.patch new file mode 100644 index 00000000000..15b26ec0644 --- /dev/null +++ b/queue-6.1/selftests-mptcp-join-fix-shellcheck-warnings.patch @@ -0,0 +1,76 @@ +From 0fcd72df8847d3a62eb34a084862157ce0564a94 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Fri, 14 Apr 2023 17:47:10 +0200 +Subject: selftests: mptcp: join: fix ShellCheck warnings + +From: Matthieu Baerts + +commit 0fcd72df8847d3a62eb34a084862157ce0564a94 upstream. + +Most of the code had an issue according to ShellCheck. + +That's mainly due to the fact it incorrectly believes most of the code +was unreachable because it's invoked by variable name, see how the +"tests" array is used. + +Once SC2317 has been ignored, three small warnings were still visible: + + - SC2155: Declare and assign separately to avoid masking return values. + + - SC2046: Quote this to prevent word splitting: can be ignored because + "ip netns pids" can display more than one pid. + + - SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. + +This probably didn't fix any actual issues but it might help spotting +new interesting warnings reported by ShellCheck as just before, +ShellCheck was reporting issues for most lines making it a bit useless. + +Signed-off-by: Matthieu Baerts +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -8,6 +8,10 @@ + + . "$(dirname "${0}")/mptcp_lib.sh" + ++# ShellCheck incorrectly believes that most of the code here is unreachable ++# because it's invoked by variable name, see how the "tests" array is used ++#shellcheck disable=SC2317 ++ + ret=0 + sin="" + sinfail="" +@@ -357,8 +361,9 @@ check_transfer() + + local line + if [ -n "$bytes" ]; then ++ local out_size + # when truncating we must check the size explicitly +- local out_size=$(wc -c $out | awk '{print $1}') ++ out_size=$(wc -c $out | awk '{print $1}') + if [ $out_size -ne $bytes ]; then + echo "[ FAIL ] $what output file has wrong size ($out_size, $bytes)" + fail_test +@@ -487,6 +492,7 @@ kill_wait() + + kill_tests_wait() + { ++ #shellcheck disable=SC2046 + kill -SIGUSR1 $(ip netns pids $ns2) $(ip netns pids $ns1) + wait + } +@@ -1726,7 +1732,7 @@ chk_subflow_nr() + + cnt1=$(ss -N $ns1 -tOni | grep -c token) + cnt2=$(ss -N $ns2 -tOni | grep -c token) +- if [ "$cnt1" != "$subflow_nr" -o "$cnt2" != "$subflow_nr" ]; then ++ if [ "$cnt1" != "$subflow_nr" ] || [ "$cnt2" != "$subflow_nr" ]; then + echo "[fail] got $cnt1:$cnt2 subflows expected $subflow_nr" + fail_test + dump_stats=1 diff --git a/queue-6.1/selftests-mptcp-join-helpers-to-skip-tests.patch b/queue-6.1/selftests-mptcp-join-helpers-to-skip-tests.patch new file mode 100644 index 00000000000..8bcdcb043d9 --- /dev/null +++ b/queue-6.1/selftests-mptcp-join-helpers-to-skip-tests.patch @@ -0,0 +1,73 @@ +From cdb50525345cf5a8359ee391032ef606a7826f08 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:38 +0200 +Subject: selftests: mptcp: join: helpers to skip tests + +From: Matthieu Baerts + +commit cdb50525345cf5a8359ee391032ef606a7826f08 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +Here are some helpers that will be used to mark subtests as skipped if a +feature is not supported. Marking as a fix for the commit introducing +this selftest to help with the backports. + +While at it, also check if kallsyms feature is available as it will also +be used in the following commits to check if MPTCP features are +available before starting a test. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: b08fbf241064 ("selftests: add test-cases for MPTCP MP_JOIN") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 27 ++++++++++++++++++++++++ + 1 file changed, 27 insertions(+) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -137,6 +137,7 @@ cleanup_partial() + check_tools() + { + mptcp_lib_check_mptcp ++ mptcp_lib_check_kallsyms + + if ! ip -Version &> /dev/null; then + echo "SKIP: Could not run test without ip tool" +@@ -183,6 +184,32 @@ cleanup() + cleanup_partial + } + ++# $1: msg ++print_title() ++{ ++ printf "%03u %-36s %s" "${TEST_COUNT}" "${TEST_NAME}" "${1}" ++} ++ ++# [ $1: fail msg ] ++mark_as_skipped() ++{ ++ local msg="${1:-"Feature not supported"}" ++ ++ mptcp_lib_fail_if_expected_feature "${msg}" ++ ++ print_title "[ skip ] ${msg}" ++ printf "\n" ++} ++ ++# $@: condition ++continue_if() ++{ ++ if ! "${@}"; then ++ mark_as_skipped ++ return 1 ++ fi ++} ++ + skip_test() + { + if [ "${#only_tests_ids[@]}" -eq 0 ] && [ "${#only_tests_names[@]}" -eq 0 ]; then diff --git a/queue-6.1/selftests-mptcp-join-skip-backup-if-set-flag-on-id-not-supported.patch b/queue-6.1/selftests-mptcp-join-skip-backup-if-set-flag-on-id-not-supported.patch new file mode 100644 index 00000000000..771ec93e5bc --- /dev/null +++ b/queue-6.1/selftests-mptcp-join-skip-backup-if-set-flag-on-id-not-supported.patch @@ -0,0 +1,69 @@ +From 07216a3c5d926bf1b6b360a0073747228a1f9b7f Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:45 +0200 +Subject: selftests: mptcp: join: skip backup if set flag on ID not supported + +From: Matthieu Baerts + +commit 07216a3c5d926bf1b6b360a0073747228a1f9b7f upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +Commit bccefb762439 ("selftests: mptcp: simplify pm_nl_change_endpoint") +has simplified the way the backup flag is set on an endpoint. Instead of +doing: + + ./pm_nl_ctl set 10.0.2.1 flags backup + +Now we do: + + ./pm_nl_ctl set id 1 flags backup + +The new way is easier to maintain but it is also incompatible with older +kernels not supporting the implicit endpoints putting in place the +infrastructure to set flags per ID, hence the second Fixes tag. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: bccefb762439 ("selftests: mptcp: simplify pm_nl_change_endpoint") +Cc: stable@vger.kernel.org +Fixes: 4cf86ae84c71 ("mptcp: strict local address ID selection") +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -2573,7 +2573,8 @@ v4mapped_tests() + backup_tests() + { + # single subflow, backup +- if reset "single subflow, backup"; then ++ if reset "single subflow, backup" && ++ continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; 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,backup +@@ -2583,7 +2584,8 @@ backup_tests() + fi + + # single address, backup +- if reset "single address, backup"; then ++ if reset "single address, backup" && ++ continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then + pm_nl_set_limits $ns1 0 1 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal + pm_nl_set_limits $ns2 1 1 +@@ -2594,7 +2596,8 @@ backup_tests() + fi + + # single address with port, backup +- if reset "single address with port, backup"; then ++ if reset "single address with port, backup" && ++ continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then + pm_nl_set_limits $ns1 0 1 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 + pm_nl_set_limits $ns2 1 1 diff --git a/queue-6.1/selftests-mptcp-join-skip-check-if-mib-counter-not-supported.patch b/queue-6.1/selftests-mptcp-join-skip-check-if-mib-counter-not-supported.patch new file mode 100644 index 00000000000..7e86f7bca90 --- /dev/null +++ b/queue-6.1/selftests-mptcp-join-skip-check-if-mib-counter-not-supported.patch @@ -0,0 +1,513 @@ +From 47867f0a7e831e24e5eab3330667ce9682d50fb1 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:39 +0200 +Subject: selftests: mptcp: join: skip check if MIB counter not supported + +From: Matthieu Baerts + +commit 47867f0a7e831e24e5eab3330667ce9682d50fb1 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the MPTCP MIB counters introduced in commit fc518953bc9c +("mptcp: add and use MIB counter infrastructure") and more later. The +MPTCP Join selftest heavily relies on these counters. + +If a counter is not supported by the kernel, it is not displayed when +using 'nstat -z'. We can then detect that and skip the verification. A +new helper (get_counter()) has been added to do the required checks and +return an error if the counter is not available. + +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 new helper also makes sure we get the exact counter we want to +avoid issues we had in the past, e.g. with MPTcpExtRmAddr and +MPTcpExtRmAddrDrop sharing the same prefix. While at it, we uniform the +way we fetch a MIB counter. + +Note for the backports: we rarely change these modified blocks so if +there is are conflicts, it is very likely because a counter is not used +in the older kernels and we don't need that chunk. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: b08fbf241064 ("selftests: add test-cases for MPTCP MP_JOIN") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 230 +++++++++++++----------- + 1 file changed, 130 insertions(+), 100 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -480,11 +480,25 @@ wait_local_port_listen() + done + } + +-rm_addr_count() ++# $1: ns ; $2: counter ++get_counter() + { +- local ns=${1} ++ local ns="${1}" ++ local counter="${2}" ++ local count ++ ++ count=$(ip netns exec ${ns} nstat -asz "${counter}" | awk 'NR==1 {next} {print $2}') ++ if [ -z "${count}" ]; then ++ mptcp_lib_fail_if_expected_feature "${counter} counter" ++ return 1 ++ fi + +- ip netns exec ${ns} nstat -as | grep MPTcpExtRmAddr | awk '{print $2}' ++ echo "${count}" ++} ++ ++rm_addr_count() ++{ ++ get_counter "${1}" "MPTcpExtRmAddr" + } + + # $1: ns, $2: old rm_addr counter in $ns +@@ -507,11 +521,11 @@ wait_mpj() + local ns="${1}" + local cnt old_cnt + +- old_cnt=$(ip netns exec ${ns} nstat -as | grep MPJoinAckRx | awk '{print $2}') ++ old_cnt=$(get_counter ${ns} "MPTcpExtMPJoinAckRx") + + local i + for i in $(seq 10); do +- cnt=$(ip netns exec ${ns} nstat -as | grep MPJoinAckRx | awk '{print $2}') ++ cnt=$(get_counter ${ns} "MPTcpExtMPJoinAckRx") + [ "$cnt" = "${old_cnt}" ] || break + sleep 0.1 + done +@@ -1191,12 +1205,13 @@ chk_csum_nr() + fi + + printf "%-${nr_blank}s %s" " " "sum" +- count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}') +- [ -z "$count" ] && count=0 ++ count=$(get_counter ${ns1} "MPTcpExtDataCsumErr") + if [ "$count" != "$csum_ns1" ]; then + extra_msg="$extra_msg ns1=$count" + fi +- if { [ "$count" != $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 0 ]; } || ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif { [ "$count" != $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 0 ]; } || + { [ "$count" -lt $csum_ns1 ] && [ $allow_multi_errors_ns1 -eq 1 ]; }; then + echo "[fail] got $count data checksum error[s] expected $csum_ns1" + fail_test +@@ -1205,12 +1220,13 @@ chk_csum_nr() + echo -n "[ ok ]" + fi + echo -n " - csum " +- count=$(ip netns exec $ns2 nstat -as | grep MPTcpExtDataCsumErr | awk '{print $2}') +- [ -z "$count" ] && count=0 ++ count=$(get_counter ${ns2} "MPTcpExtDataCsumErr") + if [ "$count" != "$csum_ns2" ]; then + extra_msg="$extra_msg ns2=$count" + fi +- if { [ "$count" != $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 0 ]; } || ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif { [ "$count" != $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 0 ]; } || + { [ "$count" -lt $csum_ns2 ] && [ $allow_multi_errors_ns2 -eq 1 ]; }; then + echo "[fail] got $count data checksum error[s] expected $csum_ns2" + fail_test +@@ -1252,12 +1268,13 @@ chk_fail_nr() + fi + + printf "%-${nr_blank}s %s" " " "ftx" +- count=$(ip netns exec $ns_tx nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}') +- [ -z "$count" ] && count=0 ++ count=$(get_counter ${ns_tx} "MPTcpExtMPFailTx") + if [ "$count" != "$fail_tx" ]; then + extra_msg="$extra_msg,tx=$count" + fi +- if { [ "$count" != "$fail_tx" ] && [ $allow_tx_lost -eq 0 ]; } || ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif { [ "$count" != "$fail_tx" ] && [ $allow_tx_lost -eq 0 ]; } || + { [ "$count" -gt "$fail_tx" ] && [ $allow_tx_lost -eq 1 ]; }; then + echo "[fail] got $count MP_FAIL[s] TX expected $fail_tx" + fail_test +@@ -1267,12 +1284,13 @@ chk_fail_nr() + fi + + echo -n " - failrx" +- count=$(ip netns exec $ns_rx nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}') +- [ -z "$count" ] && count=0 ++ count=$(get_counter ${ns_rx} "MPTcpExtMPFailRx") + if [ "$count" != "$fail_rx" ]; then + extra_msg="$extra_msg,rx=$count" + fi +- if { [ "$count" != "$fail_rx" ] && [ $allow_rx_lost -eq 0 ]; } || ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif { [ "$count" != "$fail_rx" ] && [ $allow_rx_lost -eq 0 ]; } || + { [ "$count" -gt "$fail_rx" ] && [ $allow_rx_lost -eq 1 ]; }; then + echo "[fail] got $count MP_FAIL[s] RX expected $fail_rx" + fail_test +@@ -1304,10 +1322,11 @@ chk_fclose_nr() + fi + + printf "%-${nr_blank}s %s" " " "ctx" +- count=$(ip netns exec $ns_tx nstat -as | grep MPTcpExtMPFastcloseTx | awk '{print $2}') +- [ -z "$count" ] && count=0 +- [ "$count" != "$fclose_tx" ] && extra_msg="$extra_msg,tx=$count" +- if [ "$count" != "$fclose_tx" ]; then ++ count=$(get_counter ${ns_tx} "MPTcpExtMPFastcloseTx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$fclose_tx" ]; then ++ extra_msg="$extra_msg,tx=$count" + echo "[fail] got $count MP_FASTCLOSE[s] TX expected $fclose_tx" + fail_test + dump_stats=1 +@@ -1316,10 +1335,11 @@ chk_fclose_nr() + fi + + echo -n " - fclzrx" +- count=$(ip netns exec $ns_rx nstat -as | grep MPTcpExtMPFastcloseRx | awk '{print $2}') +- [ -z "$count" ] && count=0 +- [ "$count" != "$fclose_rx" ] && extra_msg="$extra_msg,rx=$count" +- if [ "$count" != "$fclose_rx" ]; then ++ count=$(get_counter ${ns_rx} "MPTcpExtMPFastcloseRx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$fclose_rx" ]; then ++ extra_msg="$extra_msg,rx=$count" + echo "[fail] got $count MP_FASTCLOSE[s] RX expected $fclose_rx" + fail_test + dump_stats=1 +@@ -1350,9 +1370,10 @@ chk_rst_nr() + fi + + printf "%-${nr_blank}s %s" " " "rtx" +- count=$(ip netns exec $ns_tx nstat -as | grep MPTcpExtMPRstTx | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ $count -lt $rst_tx ]; then ++ count=$(get_counter ${ns_tx} "MPTcpExtMPRstTx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ $count -lt $rst_tx ]; then + echo "[fail] got $count MP_RST[s] TX expected $rst_tx" + fail_test + dump_stats=1 +@@ -1361,9 +1382,10 @@ chk_rst_nr() + fi + + echo -n " - rstrx " +- count=$(ip netns exec $ns_rx nstat -as | grep MPTcpExtMPRstRx | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" -lt "$rst_rx" ]; then ++ count=$(get_counter ${ns_rx} "MPTcpExtMPRstRx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" -lt "$rst_rx" ]; then + echo "[fail] got $count MP_RST[s] RX expected $rst_rx" + fail_test + dump_stats=1 +@@ -1384,9 +1406,10 @@ chk_infi_nr() + local dump_stats + + printf "%-${nr_blank}s %s" " " "itx" +- count=$(ip netns exec $ns2 nstat -as | grep InfiniteMapTx | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$infi_tx" ]; then ++ count=$(get_counter ${ns2} "MPTcpExtInfiniteMapTx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$infi_tx" ]; then + echo "[fail] got $count infinite map[s] TX expected $infi_tx" + fail_test + dump_stats=1 +@@ -1395,9 +1418,10 @@ chk_infi_nr() + fi + + echo -n " - infirx" +- count=$(ip netns exec $ns1 nstat -as | grep InfiniteMapRx | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$infi_rx" ]; then ++ count=$(get_counter ${ns1} "MPTcpExtInfiniteMapRx") ++ if [ -z "$count" ]; then ++ echo "[skip]" ++ elif [ "$count" != "$infi_rx" ]; then + echo "[fail] got $count infinite map[s] RX expected $infi_rx" + fail_test + dump_stats=1 +@@ -1429,9 +1453,10 @@ chk_join_nr() + fi + + printf "%03u %-36s %s" "${TEST_COUNT}" "${title}" "syn" +- count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$syn_nr" ]; then ++ count=$(get_counter ${ns1} "MPTcpExtMPJoinSynRx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$syn_nr" ]; then + echo "[fail] got $count JOIN[s] syn expected $syn_nr" + fail_test + dump_stats=1 +@@ -1441,9 +1466,10 @@ chk_join_nr() + + echo -n " - synack" + with_cookie=$(ip netns exec $ns2 sysctl -n net.ipv4.tcp_syncookies) +- count=$(ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$syn_ack_nr" ]; then ++ count=$(get_counter ${ns2} "MPTcpExtMPJoinSynAckRx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$syn_ack_nr" ]; then + # simult connections exceeding the limit with cookie enabled could go up to + # synack validation as the conn limit can be enforced reliably only after + # the subflow creation +@@ -1459,9 +1485,10 @@ chk_join_nr() + fi + + echo -n " - ack" +- count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$ack_nr" ]; then ++ count=$(get_counter ${ns1} "MPTcpExtMPJoinAckRx") ++ if [ -z "$count" ]; then ++ echo "[skip]" ++ elif [ "$count" != "$ack_nr" ]; then + echo "[fail] got $count JOIN[s] ack expected $ack_nr" + fail_test + dump_stats=1 +@@ -1493,12 +1520,12 @@ chk_stale_nr() + local recover_nr + + printf "%-${nr_blank}s %-18s" " " "stale" +- stale_nr=$(ip netns exec $ns nstat -as | grep MPTcpExtSubflowStale | awk '{print $2}') +- [ -z "$stale_nr" ] && stale_nr=0 +- recover_nr=$(ip netns exec $ns nstat -as | grep MPTcpExtSubflowRecover | awk '{print $2}') +- [ -z "$recover_nr" ] && recover_nr=0 + +- if [ $stale_nr -lt $stale_min ] || ++ stale_nr=$(get_counter ${ns} "MPTcpExtSubflowStale") ++ recover_nr=$(get_counter ${ns} "MPTcpExtSubflowRecover") ++ if [ -z "$stale_nr" ] || [ -z "$recover_nr" ]; then ++ echo "[skip]" ++ elif [ $stale_nr -lt $stale_min ] || + { [ $stale_max -gt 0 ] && [ $stale_nr -gt $stale_max ]; } || + [ $((stale_nr - recover_nr)) -ne $stale_delta ]; then + echo "[fail] got $stale_nr stale[s] $recover_nr recover[s], " \ +@@ -1534,12 +1561,12 @@ chk_add_nr() + timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout) + + printf "%-${nr_blank}s %s" " " "add" +- count=$(ip netns exec $ns2 nstat -as MPTcpExtAddAddr | grep MPTcpExtAddAddr | awk '{print $2}') +- [ -z "$count" ] && count=0 +- ++ count=$(get_counter ${ns2} "MPTcpExtAddAddr") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" + # if the test configured a short timeout tolerate greater then expected + # add addrs options, due to retransmissions +- if [ "$count" != "$add_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_nr" ]; }; then ++ elif [ "$count" != "$add_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_nr" ]; }; then + echo "[fail] got $count ADD_ADDR[s] expected $add_nr" + fail_test + dump_stats=1 +@@ -1548,9 +1575,10 @@ chk_add_nr() + fi + + echo -n " - echo " +- count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$echo_nr" ]; then ++ count=$(get_counter ${ns1} "MPTcpExtEchoAdd") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$echo_nr" ]; then + echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr" + fail_test + dump_stats=1 +@@ -1560,9 +1588,10 @@ chk_add_nr() + + if [ $port_nr -gt 0 ]; then + echo -n " - pt " +- count=$(ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$port_nr" ]; then ++ count=$(get_counter ${ns2} "MPTcpExtPortAdd") ++ if [ -z "$count" ]; then ++ echo "[skip]" ++ elif [ "$count" != "$port_nr" ]; then + echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr" + fail_test + dump_stats=1 +@@ -1571,10 +1600,10 @@ chk_add_nr() + fi + + printf "%-${nr_blank}s %s" " " "syn" +- count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx | +- awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$syn_nr" ]; then ++ count=$(get_counter ${ns1} "MPTcpExtMPJoinPortSynRx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$syn_nr" ]; then + echo "[fail] got $count JOIN[s] syn with a different \ + port-number expected $syn_nr" + fail_test +@@ -1584,10 +1613,10 @@ chk_add_nr() + fi + + echo -n " - synack" +- count=$(ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx | +- awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$syn_ack_nr" ]; then ++ count=$(get_counter ${ns2} "MPTcpExtMPJoinPortSynAckRx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$syn_ack_nr" ]; then + echo "[fail] got $count JOIN[s] synack with a different \ + port-number expected $syn_ack_nr" + fail_test +@@ -1597,10 +1626,10 @@ chk_add_nr() + fi + + echo -n " - ack" +- count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx | +- awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$ack_nr" ]; then ++ count=$(get_counter ${ns1} "MPTcpExtMPJoinPortAckRx") ++ if [ -z "$count" ]; then ++ echo "[skip]" ++ elif [ "$count" != "$ack_nr" ]; then + echo "[fail] got $count JOIN[s] ack with a different \ + port-number expected $ack_nr" + fail_test +@@ -1610,10 +1639,10 @@ chk_add_nr() + fi + + printf "%-${nr_blank}s %s" " " "syn" +- count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx | +- awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$mis_syn_nr" ]; then ++ count=$(get_counter ${ns1} "MPTcpExtMismatchPortSynRx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$mis_syn_nr" ]; then + echo "[fail] got $count JOIN[s] syn with a mismatched \ + port-number expected $mis_syn_nr" + fail_test +@@ -1623,10 +1652,10 @@ chk_add_nr() + fi + + echo -n " - ack " +- count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx | +- awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$mis_ack_nr" ]; then ++ count=$(get_counter ${ns1} "MPTcpExtMismatchPortAckRx") ++ if [ -z "$count" ]; then ++ echo "[skip]" ++ elif [ "$count" != "$mis_ack_nr" ]; then + echo "[fail] got $count JOIN[s] ack with a mismatched \ + port-number expected $mis_ack_nr" + fail_test +@@ -1670,9 +1699,10 @@ chk_rm_nr() + fi + + printf "%-${nr_blank}s %s" " " "rm " +- count=$(ip netns exec $addr_ns nstat -as | grep MPTcpExtRmAddr | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$rm_addr_nr" ]; then ++ count=$(get_counter ${addr_ns} "MPTcpExtRmAddr") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$rm_addr_nr" ]; then + echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" + fail_test + dump_stats=1 +@@ -1681,29 +1711,27 @@ chk_rm_nr() + fi + + echo -n " - rmsf " +- count=$(ip netns exec $subflow_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ -n "$simult" ]; then ++ count=$(get_counter ${subflow_ns} "MPTcpExtRmSubflow") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ -n "$simult" ]; then + local cnt suffix + +- cnt=$(ip netns exec $addr_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}') ++ cnt=$(get_counter ${addr_ns} "MPTcpExtRmSubflow") + + # in case of simult flush, the subflow removal count on each side is + # unreliable +- [ -z "$cnt" ] && cnt=0 + count=$((count + cnt)) + [ "$count" != "$rm_subflow_nr" ] && suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]" + if [ $count -ge "$rm_subflow_nr" ] && \ + [ "$count" -le "$((rm_subflow_nr *2 ))" ]; then +- echo "[ ok ] $suffix" ++ echo -n "[ ok ] $suffix" + else + echo "[fail] got $count RM_SUBFLOW[s] expected in range [$rm_subflow_nr:$((rm_subflow_nr*2))]" + fail_test + dump_stats=1 + fi +- return +- fi +- if [ "$count" != "$rm_subflow_nr" ]; then ++ elif [ "$count" != "$rm_subflow_nr" ]; then + echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr" + fail_test + dump_stats=1 +@@ -1724,9 +1752,10 @@ chk_prio_nr() + local dump_stats + + printf "%-${nr_blank}s %s" " " "ptx" +- count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$mp_prio_nr_tx" ]; then ++ count=$(get_counter ${ns1} "MPTcpExtMPPrioTx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$mp_prio_nr_tx" ]; then + echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" + fail_test + dump_stats=1 +@@ -1735,9 +1764,10 @@ chk_prio_nr() + fi + + echo -n " - prx " +- count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}') +- [ -z "$count" ] && count=0 +- if [ "$count" != "$mp_prio_nr_rx" ]; then ++ count=$(get_counter ${ns1} "MPTcpExtMPPrioRx") ++ if [ -z "$count" ]; then ++ echo "[skip]" ++ elif [ "$count" != "$mp_prio_nr_rx" ]; then + echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" + fail_test + dump_stats=1 +@@ -1813,7 +1843,7 @@ wait_attempt_fail() + while [ $time -lt $timeout_ms ]; do + local cnt + +- cnt=$(ip netns exec $ns nstat -as TcpAttemptFails | grep TcpAttemptFails | awk '{print $2}') ++ cnt=$(get_counter ${ns} "TcpAttemptFails") + + [ "$cnt" = 1 ] && return 1 + time=$((time + 100)) diff --git a/queue-6.1/selftests-mptcp-join-skip-fastclose-tests-if-not-supported.patch b/queue-6.1/selftests-mptcp-join-skip-fastclose-tests-if-not-supported.patch new file mode 100644 index 00000000000..b8ed53fabbc --- /dev/null +++ b/queue-6.1/selftests-mptcp-join-skip-fastclose-tests-if-not-supported.patch @@ -0,0 +1,68 @@ +From ae947bb2c253ff5f395bb70cb9db8700543bf398 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:42 +0200 +Subject: selftests: mptcp: join: skip Fastclose tests if not supported + +From: Matthieu Baerts + +commit ae947bb2c253ff5f395bb70cb9db8700543bf398 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the support of MP_FASTCLOSE introduced in commit +f284c0c77321 ("mptcp: implement fastclose xmit path"). + +If the MIB counter is not available, the test cannot be verified and the +behaviour will not be the expected one. So we can skip the test if the +counter is missing. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 01542c9bf9ab ("selftests: mptcp: add fastclose testcase") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -253,6 +253,19 @@ reset() + return 0 + } + ++# $1: test name ; $2: counter to check ++reset_check_counter() ++{ ++ reset "${1}" || return 1 ++ ++ local counter="${2}" ++ ++ if ! nstat -asz "${counter}" | grep -wq "${counter}"; then ++ mark_as_skipped "counter '${counter}' is not available" ++ return 1 ++ fi ++} ++ + # $1: test name + reset_with_cookies() + { +@@ -2959,14 +2972,14 @@ fullmesh_tests() + + fastclose_tests() + { +- if reset "fastclose test"; then ++ if reset_check_counter "fastclose test" "MPTcpExtMPFastcloseTx"; then + run_tests $ns1 $ns2 10.0.1.1 1024 0 fastclose_client + chk_join_nr 0 0 0 + chk_fclose_nr 1 1 + chk_rst_nr 1 1 invert + fi + +- if reset "fastclose server test"; then ++ if reset_check_counter "fastclose server test" "MPTcpExtMPFastcloseRx"; then + run_tests $ns1 $ns2 10.0.1.1 1024 0 fastclose_server + chk_join_nr 0 0 0 + chk_fclose_nr 1 1 invert diff --git a/queue-6.1/selftests-mptcp-join-skip-fullmesh-flag-tests-if-not-supported.patch b/queue-6.1/selftests-mptcp-join-skip-fullmesh-flag-tests-if-not-supported.patch new file mode 100644 index 00000000000..af992dea0e2 --- /dev/null +++ b/queue-6.1/selftests-mptcp-join-skip-fullmesh-flag-tests-if-not-supported.patch @@ -0,0 +1,76 @@ +From 9db34c4294af9999edc773d96744e2d2d4eb5060 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:46 +0200 +Subject: selftests: mptcp: join: skip fullmesh flag tests if not supported + +From: Matthieu Baerts + +commit 9db34c4294af9999edc773d96744e2d2d4eb5060 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the support of the fullmesh flag for the in-kernel PM +introduced by commit 2843ff6f36db ("mptcp: remote addresses fullmesh") +and commit 1a0d6136c5f0 ("mptcp: local addresses fullmesh"). + +It looks like there is no easy external sign we can use to predict the +expected behaviour. We could add the flag and then check if it has been +added but for that, and for each fullmesh test, we would need to setup a +new environment, do the checks, clean it and then only start the test +from yet another clean environment. To keep it simple and avoid +introducing new issues, we look for a specific kernel version. That's +not ideal but an acceptable solution for this case. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 6a0653b96f5d ("selftests: mptcp: add fullmesh setting tests") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -2936,7 +2936,8 @@ fullmesh_tests() + fi + + # set fullmesh flag +- if reset "set fullmesh flag test"; then ++ if reset "set fullmesh flag test" && ++ continue_if mptcp_lib_kversion_ge 5.18; then + pm_nl_set_limits $ns1 4 4 + pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow + pm_nl_set_limits $ns2 4 4 +@@ -2946,7 +2947,8 @@ fullmesh_tests() + fi + + # set nofullmesh flag +- if reset "set nofullmesh flag test"; then ++ if reset "set nofullmesh flag test" && ++ continue_if mptcp_lib_kversion_ge 5.18; then + pm_nl_set_limits $ns1 4 4 + pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow,fullmesh + pm_nl_set_limits $ns2 4 4 +@@ -2956,7 +2958,8 @@ fullmesh_tests() + fi + + # set backup,fullmesh flags +- if reset "set backup,fullmesh flags test"; then ++ if reset "set backup,fullmesh flags test" && ++ continue_if mptcp_lib_kversion_ge 5.18; then + pm_nl_set_limits $ns1 4 4 + pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow + pm_nl_set_limits $ns2 4 4 +@@ -2967,7 +2970,8 @@ fullmesh_tests() + fi + + # set nobackup,nofullmesh flags +- if reset "set nobackup,nofullmesh flags test"; then ++ if reset "set nobackup,nofullmesh flags test" && ++ continue_if mptcp_lib_kversion_ge 5.18; then + pm_nl_set_limits $ns1 4 4 + pm_nl_set_limits $ns2 4 4 + pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup,fullmesh diff --git a/queue-6.1/selftests-mptcp-join-skip-implicit-tests-if-not-supported.patch b/queue-6.1/selftests-mptcp-join-skip-implicit-tests-if-not-supported.patch new file mode 100644 index 00000000000..904031b8278 --- /dev/null +++ b/queue-6.1/selftests-mptcp-join-skip-implicit-tests-if-not-supported.patch @@ -0,0 +1,64 @@ +From 36c4127ae8dd0ebac6d56d8a1b272dd483471c40 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:44 +0200 +Subject: selftests: mptcp: join: skip implicit tests if not supported + +From: Matthieu Baerts + +commit 36c4127ae8dd0ebac6d56d8a1b272dd483471c40 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the support of the implicit endpoints introduced by +commit d045b9eb95a9 ("mptcp: introduce implicit endpoints"). + +It is possible to look for "mptcp_subflow_send_ack" in kallsyms because +it was needed to introduce the mentioned feature. So we can know in +advance if the feature is supported instead of trying and accepting any +results. + +Note that here and in the following commits, we re-do the same check for +each sub-test of the same function for a few reasons. The main one is +not to break the ID assign to each test in order to be able to easily +compare results between different kernel versions. Also, we can still +run a specific test even if it is skipped. Another reason is that it +makes it clear during the review that a specific subtest will be skipped +or not under certain conditions. At the end, it looks OK to call the +exact same helper multiple times: it is not a critical path and it is +the same code that is executed, not really more cases to maintain. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 69c6ce7b6eca ("selftests: mptcp: add implicit endpoint test case") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -3108,8 +3108,10 @@ userspace_tests() + + endpoint_tests() + { ++ # subflow_rebuild_header is needed to support the implicit flag + # userspace pm type prevents add_addr +- if reset "implicit EP"; then ++ if reset "implicit EP" && ++ mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then + pm_nl_set_limits $ns1 2 2 + pm_nl_set_limits $ns2 2 2 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal +@@ -3129,7 +3131,8 @@ endpoint_tests() + kill_tests_wait + fi + +- if reset "delete and re-add"; then ++ if reset "delete and re-add" && ++ mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then + pm_nl_set_limits $ns1 1 1 + pm_nl_set_limits $ns2 1 1 + pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow diff --git a/queue-6.1/selftests-mptcp-join-skip-mpc-backups-tests-if-not-supported.patch b/queue-6.1/selftests-mptcp-join-skip-mpc-backups-tests-if-not-supported.patch new file mode 100644 index 00000000000..442d5ecde7c --- /dev/null +++ b/queue-6.1/selftests-mptcp-join-skip-mpc-backups-tests-if-not-supported.patch @@ -0,0 +1,71 @@ +From 632978f0a961b4591a05ba9e39eab24541d83e84 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:49 +0200 +Subject: selftests: mptcp: join: skip MPC backups tests if not supported + +From: Matthieu Baerts + +commit 632978f0a961b4591a05ba9e39eab24541d83e84 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the support of sending an MP_PRIO signal for the initial +subflow, introduced by commit c157bbe776b7 ("mptcp: allow the in kernel +PM to set MPC subflow priority"). + +It is possible to look for "mptcp_subflow_send_ack" in kallsyms because +it was needed to introduce the mentioned feature. So we can know in +advance if the feature is supported instead of trying and accepting any +results. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 914f6a59b10f ("selftests: mptcp: add MPC backup tests") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -2607,14 +2607,16 @@ backup_tests() + chk_prio_nr 1 1 + fi + +- if reset "mpc backup"; then ++ if reset "mpc backup" && ++ continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then + pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,backup + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow + chk_join_nr 0 0 0 + chk_prio_nr 0 1 + fi + +- if reset "mpc backup both sides"; then ++ if reset "mpc backup both sides" && ++ continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then + pm_nl_add_endpoint $ns1 10.0.1.1 flags subflow,backup + pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,backup + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow +@@ -2622,14 +2624,16 @@ backup_tests() + chk_prio_nr 1 1 + fi + +- if reset "mpc switch to backup"; then ++ if reset "mpc switch to backup" && ++ continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then + pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup + chk_join_nr 0 0 0 + chk_prio_nr 0 1 + fi + +- if reset "mpc switch to backup both sides"; then ++ if reset "mpc switch to backup both sides" && ++ continue_if mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"; then + pm_nl_add_endpoint $ns1 10.0.1.1 flags subflow + pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup diff --git a/queue-6.1/selftests-mptcp-join-support-local-endpoint-being-tracked-or-not.patch b/queue-6.1/selftests-mptcp-join-support-local-endpoint-being-tracked-or-not.patch new file mode 100644 index 00000000000..5c876abed4d --- /dev/null +++ b/queue-6.1/selftests-mptcp-join-support-local-endpoint-being-tracked-or-not.patch @@ -0,0 +1,58 @@ +From d4c81bbb8600257fd3076d0196cb08bd2e5bdf24 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:41 +0200 +Subject: selftests: mptcp: join: support local endpoint being tracked or not + +From: Matthieu Baerts + +commit d4c81bbb8600257fd3076d0196cb08bd2e5bdf24 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +At some points, a new feature caused internal behaviour changes we are +verifying in the selftests, see the Fixes tag below. It was not a uAPI +change but because in these selftests, we check some internal +behaviours, it is normal we have to adapt them from time to time after +having added some features. + +It is possible to look for "mptcp_pm_subflow_check_next" in kallsyms +because it was needed to introduce the mentioned feature. So we can know +in advance what the behaviour we are expecting here instead of +supporting the two behaviours. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 86e39e04482b ("mptcp: keep track of local endpoint still available for each msk") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -2064,11 +2064,18 @@ signal_address_tests() + # the peer could possibly miss some addr notification, allow retransmission + ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow +- chk_join_nr 3 3 3 + +- # the server will not signal the address terminating +- # the MPC subflow +- chk_add_nr 3 3 ++ # It is not directly linked to the commit introducing this ++ # symbol but for the parent one which is linked anyway. ++ if ! mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then ++ chk_join_nr 3 3 2 ++ chk_add_nr 4 4 ++ else ++ chk_join_nr 3 3 3 ++ # the server will not signal the address terminating ++ # the MPC subflow ++ chk_add_nr 3 3 ++ fi + fi + } + diff --git a/queue-6.1/selftests-mptcp-join-support-rm_addr-for-used-endpoints-or-not.patch b/queue-6.1/selftests-mptcp-join-support-rm_addr-for-used-endpoints-or-not.patch new file mode 100644 index 00000000000..b22d475fe64 --- /dev/null +++ b/queue-6.1/selftests-mptcp-join-support-rm_addr-for-used-endpoints-or-not.patch @@ -0,0 +1,50 @@ +From 425ba803124b90cb9124d99f13b372a89dc151d9 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:43 +0200 +Subject: selftests: mptcp: join: support RM_ADDR for used endpoints or not + +From: Matthieu Baerts + +commit 425ba803124b90cb9124d99f13b372a89dc151d9 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +At some points, a new feature caused internal behaviour changes we are +verifying in the selftests, see the Fixes tag below. It was not a UAPI +change but because in these selftests, we check some internal +behaviours, it is normal we have to adapt them from time to time after +having added some features. + +It looks like there is no external sign we can use to predict the +expected behaviour. Instead of accepting different behaviours and thus +not really checking for the expected behaviour, we are looking here for +a specific kernel version. That's not ideal but it looks better than +removing the test because it cannot support older kernel versions. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 6fa0174a7c86 ("mptcp: more careful RM_ADDR generation") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -2329,7 +2329,12 @@ remove_tests() + pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow + run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow + chk_join_nr 3 3 3 +- chk_rm_nr 0 3 simult ++ ++ if mptcp_lib_kversion_ge 5.18; then ++ chk_rm_nr 0 3 simult ++ else ++ chk_rm_nr 3 3 ++ fi + fi + + # addresses flush diff --git a/queue-6.1/selftests-mptcp-join-use-iptables-legacy-if-available.patch b/queue-6.1/selftests-mptcp-join-use-iptables-legacy-if-available.patch new file mode 100644 index 00000000000..54f5002aef8 --- /dev/null +++ b/queue-6.1/selftests-mptcp-join-use-iptables-legacy-if-available.patch @@ -0,0 +1,85 @@ +From 0c4cd3f86a40028845ad6f8af5b37165666404cd Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:37 +0200 +Subject: selftests: mptcp: join: use 'iptables-legacy' if available + +From: Matthieu Baerts + +commit 0c4cd3f86a40028845ad6f8af5b37165666404cd upstream. + +IPTables commands using 'iptables-nft' fail on old kernels, at least +5.15 because it doesn't see the default IPTables chains: + + $ iptables -L + iptables/1.8.2 Failed to initialize nft: Protocol not supported + +As a first step before switching to NFTables, we can use iptables-legacy +if available. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 8d014eaa9254 ("selftests: mptcp: add ADD_ADDR timeout test case") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -25,6 +25,8 @@ capout="" + ns1="" + ns2="" + ksft_skip=4 ++iptables="iptables" ++ip6tables="ip6tables" + timeout_poll=30 + timeout_test=$((timeout_poll * 2 + 1)) + capture=0 +@@ -141,7 +143,11 @@ check_tools() + exit $ksft_skip + fi + +- if ! iptables -V &> /dev/null; then ++ # Use the legacy version if available to support old kernel versions ++ if iptables-legacy -V &> /dev/null; then ++ iptables="iptables-legacy" ++ ip6tables="ip6tables-legacy" ++ elif ! iptables -V &> /dev/null; then + echo "SKIP: Could not run all tests without iptables tool" + exit $ksft_skip + fi +@@ -239,9 +245,9 @@ reset_with_add_addr_timeout() + + reset "${1}" || return 1 + +- tables="iptables" ++ tables="${iptables}" + if [ $ip -eq 6 ]; then +- tables="ip6tables" ++ tables="${ip6tables}" + fi + + ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 +@@ -306,9 +312,9 @@ reset_with_fail() + local ip="${3:-4}" + local tables + +- tables="iptables" ++ tables="${iptables}" + if [ $ip -eq 6 ]; then +- tables="ip6tables" ++ tables="${ip6tables}" + fi + + ip netns exec $ns2 $tables \ +@@ -678,7 +684,7 @@ filter_tcp_from() + local src="${2}" + local target="${3}" + +- ip netns exec "${ns}" iptables -A INPUT -s "${src}" -p tcp -j "${target}" ++ ip netns exec "${ns}" ${iptables} -A INPUT -s "${src}" -p tcp -j "${target}" + } + + do_transfer() diff --git a/queue-6.1/selftests-mptcp-lib-skip-if-missing-symbol.patch b/queue-6.1/selftests-mptcp-lib-skip-if-missing-symbol.patch new file mode 100644 index 00000000000..e055c412bcc --- /dev/null +++ b/queue-6.1/selftests-mptcp-lib-skip-if-missing-symbol.patch @@ -0,0 +1,83 @@ +From 673004821ab98c6645bd21af56a290854e88f533 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:43 +0200 +Subject: selftests: mptcp: lib: skip if missing symbol + +From: Matthieu Baerts + +commit 673004821ab98c6645bd21af56a290854e88f533 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +New functions are now available to easily detect if a certain feature is +missing by looking at kallsyms. + +These new helpers are going to be used in the following commits. In +order to ease the backport of such future patches, it would be good if +this patch is backported up to the introduction of MPTCP selftests, +hence the Fixes tag below: this type of check was supposed to be done +from the beginning. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 048d19d444be ("mptcp: add basic kselftest for mptcp") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/config | 1 + tools/testing/selftests/net/mptcp/mptcp_lib.sh | 38 +++++++++++++++++++++++++ + 2 files changed, 39 insertions(+) + +--- a/tools/testing/selftests/net/mptcp/config ++++ b/tools/testing/selftests/net/mptcp/config +@@ -1,3 +1,4 @@ ++CONFIG_KALLSYMS=y + CONFIG_MPTCP=y + CONFIG_IPV6=y + CONFIG_MPTCP_IPV6=y +--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh +@@ -38,3 +38,41 @@ mptcp_lib_check_mptcp() { + exit ${KSFT_SKIP} + fi + } ++ ++mptcp_lib_check_kallsyms() { ++ if ! mptcp_lib_has_file "/proc/kallsyms"; then ++ echo "SKIP: CONFIG_KALLSYMS is missing" ++ exit ${KSFT_SKIP} ++ fi ++} ++ ++# Internal: use mptcp_lib_kallsyms_has() instead ++__mptcp_lib_kallsyms_has() { ++ local sym="${1}" ++ ++ mptcp_lib_check_kallsyms ++ ++ grep -q " ${sym}" /proc/kallsyms ++} ++ ++# $1: part of a symbol to look at, add '$' at the end for full name ++mptcp_lib_kallsyms_has() { ++ local sym="${1}" ++ ++ if __mptcp_lib_kallsyms_has "${sym}"; then ++ return 0 ++ fi ++ ++ mptcp_lib_fail_if_expected_feature "${sym} symbol not found" ++} ++ ++# $1: part of a symbol to look at, add '$' at the end for full name ++mptcp_lib_kallsyms_doesnt_have() { ++ local sym="${1}" ++ ++ if ! __mptcp_lib_kallsyms_has "${sym}"; then ++ return 0 ++ fi ++ ++ mptcp_lib_fail_if_expected_feature "${sym} symbol has been found" ++} diff --git a/queue-6.1/selftests-mptcp-lib-skip-if-not-below-kernel-version.patch b/queue-6.1/selftests-mptcp-lib-skip-if-not-below-kernel-version.patch new file mode 100644 index 00000000000..eb9568d1a60 --- /dev/null +++ b/queue-6.1/selftests-mptcp-lib-skip-if-not-below-kernel-version.patch @@ -0,0 +1,76 @@ +From b1a6a38ab8a633546cefae890da842f19e006c74 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:36 +0200 +Subject: selftests: mptcp: lib: skip if not below kernel version + +From: Matthieu Baerts + +commit b1a6a38ab8a633546cefae890da842f19e006c74 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +A new function is now available to easily detect if a feature is +missing by looking at the kernel version. That's clearly not ideal and +this kind of check should be avoided as soon as possible. But sometimes, +there are no external sign that a "feature" is available or not: +internal behaviours can change without modifying the uAPI and these +selftests are verifying the internal behaviours. Sometimes, the only +(easy) way to verify if the feature is present is to run the test but +then the validation cannot determine if there is a failure with the +feature or if the feature is missing. Then it looks better to check the +kernel version instead of having tests that can never fail. In any case, +we need a solution not to have a whole selftest being marked as failed +just because one sub-test has failed. + +Note that this env var car be set to 1 not to do such check and run the +linked sub-test: SELFTESTS_MPTCP_LIB_NO_KVERSION_CHECK. + +This new helper is going to be used in the following commits. In order +to ease the backport of such future patches, it would be good if this +patch is backported up to the introduction of MPTCP selftests, hence the +Fixes tag below: this type of check was supposed to be done from the +beginning. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 048d19d444be ("mptcp: add basic kselftest for mptcp") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_lib.sh | 26 +++++++++++++++++++++++++ + 1 file changed, 26 insertions(+) + +--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh +@@ -76,3 +76,29 @@ mptcp_lib_kallsyms_doesnt_have() { + + mptcp_lib_fail_if_expected_feature "${sym} symbol has been found" + } ++ ++# !!!AVOID USING THIS!!! ++# Features might not land in the expected version and features can be backported ++# ++# $1: kernel version, e.g. 6.3 ++mptcp_lib_kversion_ge() { ++ local exp_maj="${1%.*}" ++ local exp_min="${1#*.}" ++ local v maj min ++ ++ # If the kernel has backported features, set this env var to 1: ++ if [ "${SELFTESTS_MPTCP_LIB_NO_KVERSION_CHECK:-}" = "1" ]; then ++ return 0 ++ fi ++ ++ v=$(uname -r | cut -d'.' -f1,2) ++ maj=${v%.*} ++ min=${v#*.} ++ ++ if [ "${maj}" -gt "${exp_maj}" ] || ++ { [ "${maj}" -eq "${exp_maj}" ] && [ "${min}" -ge "${exp_min}" ]; }; then ++ return 0 ++ fi ++ ++ mptcp_lib_fail_if_expected_feature "kernel version ${1} lower than ${v}" ++} diff --git a/queue-6.1/selftests-mptcp-pm-nl-remove-hardcoded-default-limits.patch b/queue-6.1/selftests-mptcp-pm-nl-remove-hardcoded-default-limits.patch new file mode 100644 index 00000000000..1a617ef053a --- /dev/null +++ b/queue-6.1/selftests-mptcp-pm-nl-remove-hardcoded-default-limits.patch @@ -0,0 +1,62 @@ +From 2177d0b08e421971e035672b70f3228d9485c650 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:49 +0200 +Subject: selftests: mptcp: pm nl: remove hardcoded default limits + +From: Matthieu Baerts + +commit 2177d0b08e421971e035672b70f3228d9485c650 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the checks of the default limits returned by the MPTCP +in-kernel path-manager. The default values have been modified by commit +72bcbc46a5c3 ("mptcp: increase default max additional subflows to 2"). +Instead of comparing with hardcoded values, we can get the default one +and compare with them. + +Note that if we expect to have the latest version, we continue to check +the hardcoded values to avoid unexpected behaviour changes. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: eedbc685321b ("selftests: add PM netlink functional tests") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/pm_netlink.sh | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh ++++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh +@@ -73,8 +73,12 @@ check() + } + + check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list" +-check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0 ++ ++default_limits="$(ip netns exec $ns1 ./pm_nl_ctl limits)" ++if mptcp_lib_expect_all_features; then ++ check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0 + subflows 2" "defaults limits" ++fi + + ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 + ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 flags subflow dev lo +@@ -121,12 +125,10 @@ ip netns exec $ns1 ./pm_nl_ctl flush + check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "flush addrs" + + ip netns exec $ns1 ./pm_nl_ctl limits 9 1 +-check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0 +-subflows 2" "rcv addrs above hard limit" ++check "ip netns exec $ns1 ./pm_nl_ctl limits" "$default_limits" "rcv addrs above hard limit" + + ip netns exec $ns1 ./pm_nl_ctl limits 1 9 +-check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0 +-subflows 2" "subflows above hard limit" ++check "ip netns exec $ns1 ./pm_nl_ctl limits" "$default_limits" "subflows above hard limit" + + ip netns exec $ns1 ./pm_nl_ctl limits 8 8 + check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 8 diff --git a/queue-6.1/selftests-mptcp-pm-nl-skip-fullmesh-flag-checks-if-not-supported.patch b/queue-6.1/selftests-mptcp-pm-nl-skip-fullmesh-flag-checks-if-not-supported.patch new file mode 100644 index 00000000000..b07174e4e77 --- /dev/null +++ b/queue-6.1/selftests-mptcp-pm-nl-skip-fullmesh-flag-checks-if-not-supported.patch @@ -0,0 +1,63 @@ +From f3761b50b8e4cb4807b5d41e02144c8c8a0f2512 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:50 +0200 +Subject: selftests: mptcp: pm nl: skip fullmesh flag checks if not supported + +From: Matthieu Baerts + +commit f3761b50b8e4cb4807b5d41e02144c8c8a0f2512 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the fullmesh flag that can be given to the MPTCP +in-kernel path-manager and introduced in commit 2843ff6f36db ("mptcp: +remote addresses fullmesh"). + +If the flag is not visible in the dump after having set it, we don't +check the content. Note that if we expect to have this feature and +SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var is set to 1, we always +check the content to avoid regressions. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 6da1dfdd037e ("selftests: mptcp: add set_flags tests in pm_netlink.sh") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/pm_netlink.sh | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh +index 664cafc60705..d02e0d63a8f9 100755 +--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh ++++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh +@@ -178,14 +178,19 @@ subflow,backup 10.0.1.1" "set flags (backup)" + ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags nobackup + check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ + subflow 10.0.1.1" " (nobackup)" ++ ++# fullmesh support has been added later + ip netns exec $ns1 ./pm_nl_ctl set id 1 flags fullmesh +-check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ ++if ip netns exec $ns1 ./pm_nl_ctl dump | grep -q "fullmesh" || ++ mptcp_lib_expect_all_features; then ++ check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ + subflow,fullmesh 10.0.1.1" " (fullmesh)" +-ip netns exec $ns1 ./pm_nl_ctl set id 1 flags nofullmesh +-check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ ++ ip netns exec $ns1 ./pm_nl_ctl set id 1 flags nofullmesh ++ check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ + subflow 10.0.1.1" " (nofullmesh)" +-ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh +-check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ ++ ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh ++ check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \ + subflow,backup,fullmesh 10.0.1.1" " (backup,fullmesh)" ++fi + + exit $ret +-- +2.41.0 + diff --git a/queue-6.1/selftests-mptcp-remove-duplicated-entries-in-usage.patch b/queue-6.1/selftests-mptcp-remove-duplicated-entries-in-usage.patch new file mode 100644 index 00000000000..97777b9b3a6 --- /dev/null +++ b/queue-6.1/selftests-mptcp-remove-duplicated-entries-in-usage.patch @@ -0,0 +1,62 @@ +From 0a85264e48b642d360720589fdb837a3643fb9b0 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Fri, 14 Apr 2023 17:47:09 +0200 +Subject: selftests: mptcp: remove duplicated entries in usage + +From: Matthieu Baerts + +commit 0a85264e48b642d360720589fdb837a3643fb9b0 upstream. + +mptcp_connect tool was printing some duplicated entries when showing how +to use it: -j -l -r + +While at it, I also: + + - moved the very few entries that were not sorted, + + - added -R that was missing since + commit 8a4b910d005d ("mptcp: selftests: add rcvbuf set option"), + + - removed the -u parameter that has been removed in + commit f730b65c9d85 ("selftests: mptcp: try to set mptcp ulp mode in different sk states"). + +No need to backport this, it is just an internal tool used by our +selftests. The help menu is mainly useful for MPTCP kernel devs. + +Acked-by: Paolo Abeni +Signed-off-by: Matthieu Baerts +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_connect.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c ++++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c +@@ -98,8 +98,8 @@ static struct cfg_sockopt_types cfg_sock + static void die_usage(void) + { + fprintf(stderr, "Usage: mptcp_connect [-6] [-c cmsg] [-f offset] [-i file] [-I num] [-j] [-l] " +- "[-m mode] [-M mark] [-o option] [-p port] [-P mode] [-j] [-l] [-r num] " +- "[-s MPTCP|TCP] [-S num] [-r num] [-t num] [-T num] [-u] [-w sec] connect_address\n"); ++ "[-m mode] [-M mark] [-o option] [-p port] [-P mode] [-r num] [-R num] " ++ "[-s MPTCP|TCP] [-S num] [-t num] [-T num] [-w sec] connect_address\n"); + fprintf(stderr, "\t-6 use ipv6\n"); + fprintf(stderr, "\t-c cmsg -- test cmsg type \n"); + fprintf(stderr, "\t-f offset -- stop the I/O after receiving and sending the specified amount " +@@ -118,13 +118,13 @@ static void die_usage(void) + fprintf(stderr, "\t-p num -- use port num\n"); + fprintf(stderr, + "\t-P [saveWithPeek|saveAfterPeek] -- save data with/after MSG_PEEK form tcp socket\n"); +- fprintf(stderr, "\t-t num -- set poll timeout to num\n"); +- fprintf(stderr, "\t-T num -- set expected runtime to num ms\n"); + fprintf(stderr, "\t-r num -- enable slow mode, limiting each write to num bytes " + "-- for remove addr tests\n"); + fprintf(stderr, "\t-R num -- set SO_RCVBUF to num\n"); + fprintf(stderr, "\t-s [MPTCP|TCP] -- use mptcp(default) or tcp sockets\n"); + fprintf(stderr, "\t-S num -- set SO_SNDBUF to num\n"); ++ fprintf(stderr, "\t-t num -- set poll timeout to num\n"); ++ fprintf(stderr, "\t-T num -- set expected runtime to num ms\n"); + fprintf(stderr, "\t-w num -- wait num sec before closing the socket\n"); + exit(1); + } diff --git a/queue-6.1/selftests-mptcp-sockopt-relax-expected-returned-size.patch b/queue-6.1/selftests-mptcp-sockopt-relax-expected-returned-size.patch new file mode 100644 index 00000000000..2bec3d04d0a --- /dev/null +++ b/queue-6.1/selftests-mptcp-sockopt-relax-expected-returned-size.patch @@ -0,0 +1,92 @@ +From 8dee6ca2ac1e5630a7bb6a98bc0b686916fc2000 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:51 +0200 +Subject: selftests: mptcp: sockopt: relax expected returned size + +From: Matthieu Baerts + +commit 8dee6ca2ac1e5630a7bb6a98bc0b686916fc2000 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the getsockopt(SOL_MPTCP) to get info about the MPTCP +connections introduced by commit 55c42fa7fa33 ("mptcp: add MPTCP_INFO +getsockopt") and the following ones. + +We cannot guess in advance which sizes the kernel will returned: older +kernel can returned smaller sizes, e.g. recently the tcp_info structure +has been modified in commit 71fc704768f6 ("tcp: add rcv_wnd and +plb_rehash to TCP_INFO") where a new field has been added. + +The userspace can also expect a smaller size if it is compiled with old +uAPI kernel headers. + +So for these sizes, we can only check if they are above a certain +threshold, 0 for the moment. We can also only compared sizes with the +ones set by the kernel. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: ce9979129a0b ("selftests: mptcp: add mptcp getsockopt test cases") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + .../selftests/net/mptcp/mptcp_sockopt.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c +index ae61f39556ca..b35148edbf02 100644 +--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c ++++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c +@@ -87,6 +87,10 @@ struct so_state { + uint64_t tcpi_rcv_delta; + }; + ++#ifndef MIN ++#define MIN(a, b) ((a) < (b) ? (a) : (b)) ++#endif ++ + static void die_perror(const char *msg) + { + perror(msg); +@@ -349,13 +353,14 @@ static void do_getsockopt_tcp_info(struct so_state *s, int fd, size_t r, size_t + xerror("getsockopt MPTCP_TCPINFO (tries %d, %m)"); + + assert(olen <= sizeof(ti)); +- assert(ti.d.size_user == ti.d.size_kernel); +- assert(ti.d.size_user == sizeof(struct tcp_info)); ++ assert(ti.d.size_kernel > 0); ++ assert(ti.d.size_user == ++ MIN(ti.d.size_kernel, sizeof(struct tcp_info))); + assert(ti.d.num_subflows == 1); + + assert(olen > (socklen_t)sizeof(struct mptcp_subflow_data)); + olen -= sizeof(struct mptcp_subflow_data); +- assert(olen == sizeof(struct tcp_info)); ++ assert(olen == ti.d.size_user); + + if (ti.ti[0].tcpi_bytes_sent == w && + ti.ti[0].tcpi_bytes_received == r) +@@ -401,13 +406,14 @@ static void do_getsockopt_subflow_addrs(int fd) + die_perror("getsockopt MPTCP_SUBFLOW_ADDRS"); + + assert(olen <= sizeof(addrs)); +- assert(addrs.d.size_user == addrs.d.size_kernel); +- assert(addrs.d.size_user == sizeof(struct mptcp_subflow_addrs)); ++ assert(addrs.d.size_kernel > 0); ++ assert(addrs.d.size_user == ++ MIN(addrs.d.size_kernel, sizeof(struct mptcp_subflow_addrs))); + assert(addrs.d.num_subflows == 1); + + assert(olen > (socklen_t)sizeof(struct mptcp_subflow_data)); + olen -= sizeof(struct mptcp_subflow_data); +- assert(olen == sizeof(struct mptcp_subflow_addrs)); ++ assert(olen == addrs.d.size_user); + + llen = sizeof(local); + ret = getsockname(fd, (struct sockaddr *)&local, &llen); +-- +2.41.0 + diff --git a/queue-6.1/selftests-mptcp-sockopt-skip-getsockopt-checks-if-not-supported.patch b/queue-6.1/selftests-mptcp-sockopt-skip-getsockopt-checks-if-not-supported.patch new file mode 100644 index 00000000000..0a51758eac1 --- /dev/null +++ b/queue-6.1/selftests-mptcp-sockopt-skip-getsockopt-checks-if-not-supported.patch @@ -0,0 +1,52 @@ +From c6f7eccc519837ebde1d099d9610c4f1d5bd975e Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:52 +0200 +Subject: selftests: mptcp: sockopt: skip getsockopt checks if not supported + +From: Matthieu Baerts + +commit c6f7eccc519837ebde1d099d9610c4f1d5bd975e upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the getsockopt(SOL_MPTCP) to get info about the MPTCP +connections introduced by commit 55c42fa7fa33 ("mptcp: add MPTCP_INFO +getsockopt") and the following ones. + +It is possible to look for "mptcp_diag_fill_info" in kallsyms because +it is introduced by the mentioned feature. So we can know in advance if +the feature is supported and skip the sub-test if not. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: ce9979129a0b ("selftests: mptcp: add mptcp getsockopt test cases") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +@@ -84,6 +84,7 @@ cleanup() + } + + mptcp_lib_check_mptcp ++mptcp_lib_check_kallsyms + + ip -Version > /dev/null 2>&1 + if [ $? -ne 0 ];then +@@ -248,6 +249,11 @@ do_mptcp_sockopt_tests() + { + local lret=0 + ++ if ! mptcp_lib_kallsyms_has "mptcp_diag_fill_info$"; then ++ echo "INFO: MPTCP sockopt not supported: SKIP" ++ return ++ fi ++ + ip netns exec "$ns_sbox" ./mptcp_sockopt + lret=$? + diff --git a/queue-6.1/selftests-mptcp-userspace-pm-skip-if-ip-tool-is-unavailable.patch b/queue-6.1/selftests-mptcp-userspace-pm-skip-if-ip-tool-is-unavailable.patch new file mode 100644 index 00000000000..81ca76345ab --- /dev/null +++ b/queue-6.1/selftests-mptcp-userspace-pm-skip-if-ip-tool-is-unavailable.patch @@ -0,0 +1,38 @@ +From 723d6b9b12338c1caf06bf6fe269962ef04e2c71 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:54 +0200 +Subject: selftests: mptcp: userspace pm: skip if 'ip' tool is unavailable + +From: Matthieu Baerts + +commit 723d6b9b12338c1caf06bf6fe269962ef04e2c71 upstream. + +When a required tool is missing, the return code 4 (SKIP) should be +returned instead of 1 (FAIL). + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 259a834fadda ("selftests: mptcp: functional tests for the userspace PM type") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/userspace_pm.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh +index 8092399d911f..192ab818f292 100755 +--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh ++++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh +@@ -8,7 +8,7 @@ mptcp_lib_check_mptcp + ip -Version > /dev/null 2>&1 + if [ $? -ne 0 ];then + echo "SKIP: Cannot not run test without ip tool" +- exit 1 ++ exit ${KSFT_SKIP} + fi + + ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED +-- +2.41.0 + diff --git a/queue-6.1/selftests-mptcp-userspace-pm-skip-if-not-supported.patch b/queue-6.1/selftests-mptcp-userspace-pm-skip-if-not-supported.patch new file mode 100644 index 00000000000..2b0fd0af172 --- /dev/null +++ b/queue-6.1/selftests-mptcp-userspace-pm-skip-if-not-supported.patch @@ -0,0 +1,47 @@ +From f90adb033891d418c5dafef34a9aa49f3c860991 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:55 +0200 +Subject: selftests: mptcp: userspace pm: skip if not supported + +From: Matthieu Baerts + +commit f90adb033891d418c5dafef34a9aa49f3c860991 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the MPTCP Userspace PM introduced by commit 4638de5aefe5 +("mptcp: handle local addrs announced by userspace PMs"). + +We can skip all these tests if the feature is not supported simply by +looking for the MPTCP pm_type's sysctl knob. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 259a834fadda ("selftests: mptcp: functional tests for the userspace PM type") +Cc: stable@vger.kernel.org +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/userspace_pm.sh | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh +index 192ab818f292..38a1d34f7b4d 100755 +--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh ++++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh +@@ -5,6 +5,11 @@ + + mptcp_lib_check_mptcp + ++if ! mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then ++ echo "userspace pm tests are not supported by the kernel: SKIP" ++ exit ${KSFT_SKIP} ++fi ++ + ip -Version > /dev/null 2>&1 + if [ $? -ne 0 ];then + echo "SKIP: Cannot not run test without ip tool" +-- +2.41.0 + diff --git a/queue-6.1/series b/queue-6.1/series index 817eb590436..2e97bb84958 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -11,3 +11,25 @@ ksmbd-validate-command-payload-size.patch ksmbd-fix-out-of-bound-read-in-smb2_write.patch ksmbd-validate-session-id-and-tree-id-in-the-compound-request.patch tick-common-align-tick-period-during-sched_timer-setup.patch +selftests-mptcp-remove-duplicated-entries-in-usage.patch +selftests-mptcp-join-fix-shellcheck-warnings.patch +selftests-mptcp-lib-skip-if-missing-symbol.patch +selftests-mptcp-connect-skip-transp-tests-if-not-supported.patch +selftests-mptcp-connect-skip-disconnect-tests-if-not-supported.patch +selftests-mptcp-pm-nl-remove-hardcoded-default-limits.patch +selftests-mptcp-pm-nl-skip-fullmesh-flag-checks-if-not-supported.patch +selftests-mptcp-sockopt-relax-expected-returned-size.patch +selftests-mptcp-sockopt-skip-getsockopt-checks-if-not-supported.patch +selftests-mptcp-userspace-pm-skip-if-ip-tool-is-unavailable.patch +selftests-mptcp-userspace-pm-skip-if-not-supported.patch +selftests-mptcp-lib-skip-if-not-below-kernel-version.patch +selftests-mptcp-join-use-iptables-legacy-if-available.patch +selftests-mptcp-join-helpers-to-skip-tests.patch +selftests-mptcp-join-skip-check-if-mib-counter-not-supported.patch +selftests-mptcp-join-support-local-endpoint-being-tracked-or-not.patch +selftests-mptcp-join-skip-fastclose-tests-if-not-supported.patch +selftests-mptcp-join-support-rm_addr-for-used-endpoints-or-not.patch +selftests-mptcp-join-skip-implicit-tests-if-not-supported.patch +selftests-mptcp-join-skip-backup-if-set-flag-on-id-not-supported.patch +selftests-mptcp-join-skip-fullmesh-flag-tests-if-not-supported.patch +selftests-mptcp-join-skip-mpc-backups-tests-if-not-supported.patch