From: Greg Kroah-Hartman Date: Thu, 22 Jun 2023 08:08:21 +0000 (+0200) Subject: 6.3-stable patches X-Git-Tag: v4.14.320~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9ee0c47048040041bf417c67d3d51bd7042e6f18;p=thirdparty%2Fkernel%2Fstable-queue.git 6.3-stable patches added patches: riscv-link-with-z-norelro.patch selftests-mptcp-connect-skip-disconnect-tests-if-not-supported.patch selftests-mptcp-connect-skip-tfo-tests-if-not-supported.patch selftests-mptcp-connect-skip-transp-tests-if-not-supported.patch selftests-mptcp-diag-skip-inuse-tests-if-not-supported.patch selftests-mptcp-diag-skip-listen-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-fail-tests-if-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-mixed-tests-if-not-supported.patch selftests-mptcp-join-skip-mpc-backups-tests-if-not-supported.patch selftests-mptcp-join-skip-pm-listener-tests-if-not-supported.patch selftests-mptcp-join-skip-test-if-iptables-tc-cmds-fail.patch selftests-mptcp-join-skip-userspace-pm-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-uniform-listener-tests.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-sockopt-skip-tcp_inq-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-userspace-pm-skip-pm-listener-events-tests-if-unavailable.patch --- diff --git a/queue-6.3/riscv-link-with-z-norelro.patch b/queue-6.3/riscv-link-with-z-norelro.patch new file mode 100644 index 00000000000..ff72914b35a --- /dev/null +++ b/queue-6.3/riscv-link-with-z-norelro.patch @@ -0,0 +1,49 @@ +From nathan@kernel.org Thu Jun 22 09:37:45 2023 +From: Nathan Chancellor +Date: Tue, 20 Jun 2023 17:44:50 +0000 +Subject: riscv: Link with '-z norelro' +To: gregkh@linuxfoundation.org, sashal@kernel.org +Cc: palmer@dabbelt.com, conor@kernel.org, ndesaulniers@google.com, nathan@kernel.org, linux-riscv@lists.infradead.org, stable@vger.kernel.org, llvm@lists.linux.dev, kernel test robot +Message-ID: <20230620-6-3-fix-got-relro-error-lld-v1-1-f3e71ec912d1@kernel.org> + +From: Nathan Chancellor + +This patch fixes a stable only patch, so it has no direct upstream +equivalent. + +After a stable only patch to explicitly handle the '.got' section to +handle an orphan section warning from the linker, certain configurations +error when linking with ld.lld, which enables relro by default: + + ld.lld: error: section: .got is not contiguous with other relro sections + +This has come up with other architectures before, such as arm and arm64 +in commit 0cda9bc15dfc ("ARM: 9038/1: Link with '-z norelro'") and +commit 3b92fa7485eb ("arm64: link with -z norelro regardless of +CONFIG_RELOCATABLE"). Additionally, '-z norelro' is used unconditionally +for RISC-V upstream after commit 26e7aacb83df ("riscv: Allow to +downgrade paging mode from the command line"), which alluded to this +issue for the same reason. Bring 6.3 in line with mainline and link with +'-z norelro', which resolves the above link failure. + +Fixes: e6d1562dd4e9 ("riscv: vmlinux.lds.S: Explicitly handle '.got' section") +Reported-by: kernel test robot +Closes: https://lore.kernel.org/oe-kbuild-all/202306192231.DJmWr6BX-lkp@intel.com/ +Signed-off-by: Nathan Chancellor +Acked-by: Palmer Dabbelt +Signed-off-by: Greg Kroah-Hartman +--- + arch/riscv/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/riscv/Makefile ++++ b/arch/riscv/Makefile +@@ -7,7 +7,7 @@ + # + + OBJCOPYFLAGS := -O binary +-LDFLAGS_vmlinux := ++LDFLAGS_vmlinux := -z norelro + ifeq ($(CONFIG_DYNAMIC_FTRACE),y) + LDFLAGS_vmlinux := --no-relax + KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY diff --git a/queue-6.3/selftests-mptcp-connect-skip-disconnect-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-connect-skip-disconnect-tests-if-not-supported.patch new file mode 100644 index 00000000000..e4e3e83680d --- /dev/null +++ b/queue-6.3/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 +@@ -797,6 +797,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.3/selftests-mptcp-connect-skip-tfo-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-connect-skip-tfo-tests-if-not-supported.patch new file mode 100644 index 00000000000..84c7b91c3c6 --- /dev/null +++ b/queue-6.3/selftests-mptcp-connect-skip-tfo-tests-if-not-supported.patch @@ -0,0 +1,43 @@ +From 06b03083158e90d57866fa220de92c8dd8b9598b Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:46 +0200 +Subject: selftests: mptcp: connect: skip TFO tests if not supported + +From: Matthieu Baerts + +commit 06b03083158e90d57866fa220de92c8dd8b9598b 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 TCP_FASTOPEN socket option with MPTCP +connections introduced by commit 4ffb0a02346c ("mptcp: add TCP_FASTOPEN +sock option"). + +It is possible to look for "mptcp_fastopen_" in kallsyms to know if the +feature is supported or not. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: ca7ae8916043 ("selftests: mptcp: mptfo Initiator/Listener") +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 +@@ -777,6 +777,11 @@ run_tests_peekmode() + + run_tests_mptfo() + { ++ if ! mptcp_lib_kallsyms_has "mptcp_fastopen_"; then ++ echo "INFO: TFO not supported by the kernel: SKIP" ++ return ++ fi ++ + echo "INFO: with MPTFO start" + ip netns exec "$ns1" sysctl -q net.ipv4.tcp_fastopen=2 + ip netns exec "$ns2" sysctl -q net.ipv4.tcp_fastopen=1 diff --git a/queue-6.3/selftests-mptcp-connect-skip-transp-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-connect-skip-transp-tests-if-not-supported.patch new file mode 100644 index 00000000000..a1513ed3a16 --- /dev/null +++ b/queue-6.3/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 +@@ -695,6 +696,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.3/selftests-mptcp-diag-skip-inuse-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-diag-skip-inuse-tests-if-not-supported.patch new file mode 100644 index 00000000000..aaf21ac8352 --- /dev/null +++ b/queue-6.3/selftests-mptcp-diag-skip-inuse-tests-if-not-supported.patch @@ -0,0 +1,46 @@ +From dc93086aff040349b5b2a4608c71ea01286dc2cc Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:48 +0200 +Subject: selftests: mptcp: diag: skip inuse tests if not supported + +From: Matthieu Baerts + +commit dc93086aff040349b5b2a4608c71ea01286dc2cc upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the reporting of the MPTCP sockets being used, introduced +by commit c558246ee73e ("mptcp: add statistics for mptcp socket in use"). + +Similar to the parent commit, it looks like there is no good pre-check +to do here, i.e. dedicated function available in kallsyms. Instead, we +try to get info and if nothing is returned, the test is marked as +skipped. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: e04a30f78809 ("selftest: mptcp: add test for mptcp socket in use") +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/diag.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh +index 4a6165389b74..fa9e09ad97d9 100755 +--- a/tools/testing/selftests/net/mptcp/diag.sh ++++ b/tools/testing/selftests/net/mptcp/diag.sh +@@ -173,7 +173,7 @@ chk_msk_inuse() + sleep 0.1 + done + +- __chk_nr get_msk_inuse $expected "$msg" ++ __chk_nr get_msk_inuse $expected "$msg" 0 + } + + # $1: ns, $2: port +-- +2.41.0 + diff --git a/queue-6.3/selftests-mptcp-diag-skip-listen-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-diag-skip-listen-tests-if-not-supported.patch new file mode 100644 index 00000000000..e824e93458a --- /dev/null +++ b/queue-6.3/selftests-mptcp-diag-skip-listen-tests-if-not-supported.patch @@ -0,0 +1,142 @@ +From dc97251bf0b70549c76ba261516c01b8096771c5 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:47 +0200 +Subject: selftests: mptcp: diag: skip listen tests if not supported + +From: Matthieu Baerts + +commit dc97251bf0b70549c76ba261516c01b8096771c5 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the listen diag dump support introduced by +commit 4fa39b701ce9 ("mptcp: listen diag dump support"). + +It looks like there is no good pre-check to do here, i.e. dedicated +function available in kallsyms. Instead, we try to get info if nothing +is returned, the test is marked as skipped. + +That's not ideal because something could be wrong with the feature and +instead of reporting an error, the test could be marked as skipped. If +we know in advanced that the feature is supposed to be supported, the +tester can set SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var to 1: in +this case the test will report an error instead of marking the test as +skipped if nothing is returned. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: f2ae0fa68e28 ("selftests/mptcp: add diag listen 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/diag.sh | 42 ++++++++++++------------------ + 1 file changed, 17 insertions(+), 25 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/diag.sh ++++ b/tools/testing/selftests/net/mptcp/diag.sh +@@ -55,16 +55,20 @@ __chk_nr() + { + local command="$1" + local expected=$2 +- local msg nr ++ local msg="$3" ++ local skip="${4:-SKIP}" ++ local nr + +- shift 2 +- msg=$* + nr=$(eval $command) + + printf "%-50s" "$msg" + if [ $nr != $expected ]; then +- echo "[ fail ] expected $expected found $nr" +- ret=$test_cnt ++ if [ $nr = "$skip" ] && ! mptcp_lib_expect_all_features; then ++ echo "[ skip ] Feature probably not supported" ++ else ++ echo "[ fail ] expected $expected found $nr" ++ ret=$test_cnt ++ fi + else + echo "[ ok ]" + fi +@@ -76,12 +80,12 @@ __chk_msk_nr() + local condition=$1 + shift 1 + +- __chk_nr "ss -inmHMN $ns | $condition" $* ++ __chk_nr "ss -inmHMN $ns | $condition" "$@" + } + + chk_msk_nr() + { +- __chk_msk_nr "grep -c token:" $* ++ __chk_msk_nr "grep -c token:" "$@" + } + + wait_msk_nr() +@@ -119,37 +123,26 @@ wait_msk_nr() + + chk_msk_fallback_nr() + { +- __chk_msk_nr "grep -c fallback" $* ++ __chk_msk_nr "grep -c fallback" "$@" + } + + chk_msk_remote_key_nr() + { +- __chk_msk_nr "grep -c remote_key" $* ++ __chk_msk_nr "grep -c remote_key" "$@" + } + + __chk_listen() + { + local filter="$1" + local expected=$2 ++ local msg="$3" + +- shift 2 +- msg=$* +- +- nr=$(ss -N $ns -Ml "$filter" | grep -c LISTEN) +- printf "%-50s" "$msg" +- +- if [ $nr != $expected ]; then +- echo "[ fail ] expected $expected found $nr" +- ret=$test_cnt +- else +- echo "[ ok ]" +- fi ++ __chk_nr "ss -N $ns -Ml '$filter' | grep -c LISTEN" "$expected" "$msg" 0 + } + + chk_msk_listen() + { + lport=$1 +- local msg="check for listen socket" + + # destination port search should always return empty list + __chk_listen "dport $lport" 0 "listen match for dport $lport" +@@ -167,10 +160,9 @@ chk_msk_listen() + chk_msk_inuse() + { + local expected=$1 ++ local msg="$2" + local listen_nr + +- shift 1 +- + listen_nr=$(ss -N "${ns}" -Ml | grep -c LISTEN) + expected=$((expected + listen_nr)) + +@@ -181,7 +173,7 @@ chk_msk_inuse() + sleep 0.1 + done + +- __chk_nr get_msk_inuse $expected $* ++ __chk_nr get_msk_inuse $expected "$msg" + } + + # $1: ns, $2: port diff --git a/queue-6.3/selftests-mptcp-join-fix-shellcheck-warnings.patch b/queue-6.3/selftests-mptcp-join-fix-shellcheck-warnings.patch new file mode 100644 index 00000000000..70c65c5744e --- /dev/null +++ b/queue-6.3/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="" +@@ -377,8 +381,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 +@@ -513,6 +518,7 @@ kill_events_pids() + + kill_tests_wait() + { ++ #shellcheck disable=SC2046 + kill -SIGUSR1 $(ip netns pids $ns2) $(ip netns pids $ns1) + wait + } +@@ -1725,7 +1731,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.3/selftests-mptcp-join-helpers-to-skip-tests.patch b/queue-6.3/selftests-mptcp-join-helpers-to-skip-tests.patch new file mode 100644 index 00000000000..fc458796170 --- /dev/null +++ b/queue-6.3/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 +@@ -142,6 +142,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" +@@ -191,6 +192,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.3/selftests-mptcp-join-skip-backup-if-set-flag-on-id-not-supported.patch b/queue-6.3/selftests-mptcp-join-skip-backup-if-set-flag-on-id-not-supported.patch new file mode 100644 index 00000000000..8d830989b13 --- /dev/null +++ b/queue-6.3/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 +@@ -2639,7 +2639,8 @@ mixed_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 +@@ -2649,7 +2650,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 +@@ -2660,7 +2662,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.3/selftests-mptcp-join-skip-check-if-mib-counter-not-supported.patch b/queue-6.3/selftests-mptcp-join-skip-check-if-mib-counter-not-supported.patch new file mode 100644 index 00000000000..ce61f441700 --- /dev/null +++ b/queue-6.3/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 +@@ -500,11 +500,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 +@@ -527,11 +541,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 +@@ -1190,12 +1204,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 +@@ -1204,12 +1219,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 +@@ -1251,12 +1267,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 +@@ -1266,12 +1283,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 +@@ -1303,10 +1321,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 +@@ -1315,10 +1334,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 +@@ -1349,9 +1369,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 +@@ -1360,9 +1381,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 +@@ -1383,9 +1405,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 +@@ -1394,9 +1417,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 +@@ -1428,9 +1452,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 +@@ -1440,9 +1465,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 +@@ -1458,9 +1484,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 +@@ -1492,12 +1519,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], " \ +@@ -1533,12 +1560,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 +@@ -1547,9 +1574,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 +@@ -1559,9 +1587,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 +@@ -1570,10 +1599,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 +@@ -1583,10 +1612,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 +@@ -1596,10 +1625,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 +@@ -1609,10 +1638,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 +@@ -1622,10 +1651,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 +@@ -1669,9 +1698,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 +@@ -1680,29 +1710,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 +@@ -1723,9 +1751,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 +@@ -1734,9 +1763,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 +@@ -1812,7 +1842,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.3/selftests-mptcp-join-skip-fail-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-join-skip-fail-tests-if-not-supported.patch new file mode 100644 index 00000000000..c64addf3090 --- /dev/null +++ b/queue-6.3/selftests-mptcp-join-skip-fail-tests-if-not-supported.patch @@ -0,0 +1,41 @@ +From ff8897b5189495b47895ca247b860a29dc04b36b Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:48 +0200 +Subject: selftests: mptcp: join: skip fail tests if not supported + +From: Matthieu Baerts + +commit ff8897b5189495b47895ca247b860a29dc04b36b 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 MP_FAIL / infinite mapping introduced +by commit 1e39e5a32ad7 ("mptcp: infinite mapping sending") and the +following ones. + +It is possible to look for one of the infinite mapping counters to know +in advance if the this feature is available. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: b6e074e171bc ("selftests: mptcp: add infinite map testcase") +Cc: stable@vger.kernel.org +Fixes: 2ba18161d407 ("selftests: mptcp: add MP_FAIL reset testcase") +Signed-off-by: Matthieu Baerts +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -384,7 +384,7 @@ setup_fail_rules() + + reset_with_fail() + { +- reset "${1}" || return 1 ++ reset_check_counter "${1}" "MPTcpExtInfiniteMapTx" || return 1 + shift + + ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=1 diff --git a/queue-6.3/selftests-mptcp-join-skip-fastclose-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-join-skip-fastclose-tests-if-not-supported.patch new file mode 100644 index 00000000000..ee249bd2df1 --- /dev/null +++ b/queue-6.3/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 +@@ -261,6 +261,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() + { +@@ -3081,14 +3094,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.3/selftests-mptcp-join-skip-fullmesh-flag-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-join-skip-fullmesh-flag-tests-if-not-supported.patch new file mode 100644 index 00000000000..80de3da8430 --- /dev/null +++ b/queue-6.3/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 +@@ -3058,7 +3058,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 +@@ -3068,7 +3069,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 +@@ -3078,7 +3080,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 +@@ -3089,7 +3092,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.3/selftests-mptcp-join-skip-implicit-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-join-skip-implicit-tests-if-not-supported.patch new file mode 100644 index 00000000000..32168d4ba99 --- /dev/null +++ b/queue-6.3/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 +@@ -3232,8 +3232,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 +@@ -3253,7 +3255,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.3/selftests-mptcp-join-skip-mixed-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-join-skip-mixed-tests-if-not-supported.patch new file mode 100644 index 00000000000..2c225db2c5d --- /dev/null +++ b/queue-6.3/selftests-mptcp-join-skip-mixed-tests-if-not-supported.patch @@ -0,0 +1,74 @@ +From 6673851be0fc1bfc3353ffb52ff26ae5468f12c9 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:52 +0200 +Subject: selftests: mptcp: join: skip mixed tests if not supported + +From: Matthieu Baerts + +commit 6673851be0fc1bfc3353ffb52ff26ae5468f12c9 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 a mix of subflows in v4 and v6 by the +in-kernel PM introduced by commit b9d69db87fb7 ("mptcp: let the +in-kernel PM use mixed IPv4 and IPv6 addresses"). + +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: ad3493746ebe ("selftests: mptcp: add test-cases for mixed v4/v6 subflows") +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 +@@ -2597,7 +2597,8 @@ v4mapped_tests() + + mixed_tests() + { +- if reset "IPv4 sockets do not use IPv6 addresses"; then ++ if reset "IPv4 sockets do not use IPv6 addresses" && ++ continue_if mptcp_lib_kversion_ge 6.3; then + pm_nl_set_limits $ns1 0 1 + pm_nl_set_limits $ns2 1 1 + pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal +@@ -2606,7 +2607,8 @@ mixed_tests() + fi + + # Need an IPv6 mptcp socket to allow subflows of both families +- if reset "simult IPv4 and IPv6 subflows"; then ++ if reset "simult IPv4 and IPv6 subflows" && ++ continue_if mptcp_lib_kversion_ge 6.3; then + pm_nl_set_limits $ns1 0 1 + pm_nl_set_limits $ns2 1 1 + pm_nl_add_endpoint $ns1 10.0.1.1 flags signal +@@ -2615,7 +2617,8 @@ mixed_tests() + fi + + # cross families subflows will not be created even in fullmesh mode +- if reset "simult IPv4 and IPv6 subflows, fullmesh 1x1"; then ++ if reset "simult IPv4 and IPv6 subflows, fullmesh 1x1" && ++ continue_if mptcp_lib_kversion_ge 6.3; then + pm_nl_set_limits $ns1 0 4 + pm_nl_set_limits $ns2 1 4 + pm_nl_add_endpoint $ns2 dead:beef:2::2 flags subflow,fullmesh +@@ -2626,7 +2629,8 @@ mixed_tests() + + # fullmesh still tries to create all the possibly subflows with + # matching family +- if reset "simult IPv4 and IPv6 subflows, fullmesh 2x2"; then ++ if reset "simult IPv4 and IPv6 subflows, fullmesh 2x2" && ++ continue_if mptcp_lib_kversion_ge 6.3; then + pm_nl_set_limits $ns1 0 4 + pm_nl_set_limits $ns2 2 4 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal diff --git a/queue-6.3/selftests-mptcp-join-skip-mpc-backups-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-join-skip-mpc-backups-tests-if-not-supported.patch new file mode 100644 index 00000000000..44623e6086a --- /dev/null +++ b/queue-6.3/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 +@@ -2673,14 +2673,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 +@@ -2688,14 +2690,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.3/selftests-mptcp-join-skip-pm-listener-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-join-skip-pm-listener-tests-if-not-supported.patch new file mode 100644 index 00000000000..a36e10fa9ba --- /dev/null +++ b/queue-6.3/selftests-mptcp-join-skip-pm-listener-tests-if-not-supported.patch @@ -0,0 +1,42 @@ +From 0471bb479af03874b09350fcfe51d3743a5608de Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:50 +0200 +Subject: selftests: mptcp: join: skip PM listener tests if not supported + +From: Matthieu Baerts + +commit 0471bb479af03874b09350fcfe51d3743a5608de 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 PM listener events introduced by commit +f8c9dfbd875b ("mptcp: add pm listener events"). + +It is possible to look for "mptcp_event_pm_listener" in kallsyms to know +in advance if the kernel supports this feature. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 178d023208eb ("selftests: mptcp: listener test for in-kernel PM") +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 | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -2734,6 +2734,11 @@ verify_listener_events() + $e_saddr $e_sport + fi + ++ if ! mptcp_lib_kallsyms_has "mptcp_event_pm_listener$"; then ++ printf "[skip]: event not supported\n" ++ return ++ fi ++ + type=$(grep "type:$e_type," $evt | + sed --unbuffered -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q') + family=$(grep "type:$e_type," $evt | diff --git a/queue-6.3/selftests-mptcp-join-skip-test-if-iptables-tc-cmds-fail.patch b/queue-6.3/selftests-mptcp-join-skip-test-if-iptables-tc-cmds-fail.patch new file mode 100644 index 00000000000..a2ab70d9bac --- /dev/null +++ b/queue-6.3/selftests-mptcp-join-skip-test-if-iptables-tc-cmds-fail.patch @@ -0,0 +1,199 @@ +From 4a0b866a3f7d3c22033f40e93e94befc6fe51bce Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:40 +0200 +Subject: selftests: mptcp: join: skip test if iptables/tc cmds fail + +From: Matthieu Baerts + +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@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 | 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 diff --git a/queue-6.3/selftests-mptcp-join-skip-userspace-pm-tests-if-not-supported.patch b/queue-6.3/selftests-mptcp-join-skip-userspace-pm-tests-if-not-supported.patch new file mode 100644 index 00000000000..9ce34a7a062 --- /dev/null +++ b/queue-6.3/selftests-mptcp-join-skip-userspace-pm-tests-if-not-supported.patch @@ -0,0 +1,120 @@ +From f2b492b04a167261e1c38eb76f78fb4294473a49 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:47 +0200 +Subject: selftests: mptcp: join: skip userspace PM tests if not supported + +From: Matthieu Baerts + +commit f2b492b04a167261e1c38eb76f78fb4294473a49 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 userspace PM introduced by commit +4638de5aefe5 ("mptcp: handle local addrs announced by userspace PMs") +and the following ones. + +It is possible to look for the MPTCP pm_type's sysctl knob to know in +advance if the userspace PM is available. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 5ac1d2d63451 ("selftests: mptcp: Add tests for 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/mptcp_join.sh | 26 +++++++++++++++--------- + 1 file changed, 17 insertions(+), 9 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -84,7 +84,7 @@ init_partial() + ip netns add $netns || exit $ksft_skip + ip -net $netns link set lo up + ip netns exec $netns sysctl -q net.mptcp.enabled=1 +- ip netns exec $netns sysctl -q net.mptcp.pm_type=0 ++ ip netns exec $netns sysctl -q net.mptcp.pm_type=0 2>/dev/null || true + ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0 + ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0 + if [ $checksum -eq 1 ]; then +@@ -3151,7 +3151,8 @@ fail_tests() + userspace_tests() + { + # userspace pm type prevents add_addr +- if reset "userspace pm type prevents add_addr"; then ++ if reset "userspace pm type prevents add_addr" && ++ continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns1 + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 0 2 +@@ -3162,7 +3163,8 @@ userspace_tests() + fi + + # userspace pm type does not echo add_addr without daemon +- if reset "userspace pm no echo w/o daemon"; then ++ if reset "userspace pm no echo w/o daemon" && ++ continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns2 + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 0 2 +@@ -3173,7 +3175,8 @@ userspace_tests() + fi + + # userspace pm type rejects join +- if reset "userspace pm type rejects join"; then ++ if reset "userspace pm type rejects join" && ++ continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns1 + pm_nl_set_limits $ns1 1 1 + pm_nl_set_limits $ns2 1 1 +@@ -3183,7 +3186,8 @@ userspace_tests() + fi + + # userspace pm type does not send join +- if reset "userspace pm type does not send join"; then ++ if reset "userspace pm type does not send join" && ++ continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns2 + pm_nl_set_limits $ns1 1 1 + pm_nl_set_limits $ns2 1 1 +@@ -3193,7 +3197,8 @@ userspace_tests() + fi + + # userspace pm type prevents mp_prio +- if reset "userspace pm type prevents mp_prio"; then ++ if reset "userspace pm type prevents mp_prio" && ++ continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns1 + pm_nl_set_limits $ns1 1 1 + pm_nl_set_limits $ns2 1 1 +@@ -3204,7 +3209,8 @@ userspace_tests() + fi + + # userspace pm type prevents rm_addr +- if reset "userspace pm type prevents rm_addr"; then ++ if reset "userspace pm type prevents rm_addr" && ++ continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns1 + set_userspace_pm $ns2 + pm_nl_set_limits $ns1 0 1 +@@ -3216,7 +3222,8 @@ userspace_tests() + fi + + # userspace pm add & remove address +- if reset_with_events "userspace pm add & remove address"; then ++ if reset_with_events "userspace pm add & remove address" && ++ continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns1 + pm_nl_set_limits $ns2 1 1 + run_tests $ns1 $ns2 10.0.1.1 0 userspace_1 0 slow +@@ -3227,7 +3234,8 @@ userspace_tests() + fi + + # userspace pm create destroy subflow +- if reset_with_events "userspace pm create destroy subflow"; then ++ if reset_with_events "userspace pm create destroy subflow" && ++ continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns2 + pm_nl_set_limits $ns1 0 1 + run_tests $ns1 $ns2 10.0.1.1 0 0 userspace_1 slow diff --git a/queue-6.3/selftests-mptcp-join-support-local-endpoint-being-tracked-or-not.patch b/queue-6.3/selftests-mptcp-join-support-local-endpoint-being-tracked-or-not.patch new file mode 100644 index 00000000000..be02c701b92 --- /dev/null +++ b/queue-6.3/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 +@@ -2089,11 +2089,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.3/selftests-mptcp-join-support-rm_addr-for-used-endpoints-or-not.patch b/queue-6.3/selftests-mptcp-join-support-rm_addr-for-used-endpoints-or-not.patch new file mode 100644 index 00000000000..447d7130bf2 --- /dev/null +++ b/queue-6.3/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 +@@ -2354,7 +2354,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.3/selftests-mptcp-join-uniform-listener-tests.patch b/queue-6.3/selftests-mptcp-join-uniform-listener-tests.patch new file mode 100644 index 00000000000..ba842747283 --- /dev/null +++ b/queue-6.3/selftests-mptcp-join-uniform-listener-tests.patch @@ -0,0 +1,88 @@ +From 96b84195df61d374d8028cf426a115ae085031ec Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Sat, 10 Jun 2023 18:11:51 +0200 +Subject: selftests: mptcp: join: uniform listener tests + +From: Matthieu Baerts + +commit 96b84195df61d374d8028cf426a115ae085031ec upstream. + +The alignment was different from the other tests because tabs were used +instead of spaces. + +While at it, also use 'echo' instead of 'printf' to print the result to +keep the same style as done in the other sub-tests. And, even if it +should be better with, also remove 'stdbuf' and sed's '--unbuffered' +option because they are not used in the other subtests and they are not +available when using a minimal environment with busybox. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 178d023208eb ("selftests: mptcp: listener test for in-kernel PM") +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 | 30 +++++++++++------------- + 1 file changed, 14 insertions(+), 16 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -2725,43 +2725,41 @@ verify_listener_events() + local family + local saddr + local sport ++ local name + + if [ $e_type = $LISTENER_CREATED ]; then +- stdbuf -o0 -e0 printf "\t\t\t\t\t CREATE_LISTENER %s:%s"\ +- $e_saddr $e_sport ++ name="LISTENER_CREATED" + elif [ $e_type = $LISTENER_CLOSED ]; then +- stdbuf -o0 -e0 printf "\t\t\t\t\t CLOSE_LISTENER %s:%s "\ +- $e_saddr $e_sport ++ name="LISTENER_CLOSED" ++ else ++ name="$e_type" + fi + ++ printf "%-${nr_blank}s %s %s:%s " " " "$name" "$e_saddr" "$e_sport" ++ + if ! mptcp_lib_kallsyms_has "mptcp_event_pm_listener$"; then + printf "[skip]: event not supported\n" + return + fi + +- type=$(grep "type:$e_type," $evt | +- sed --unbuffered -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q') +- family=$(grep "type:$e_type," $evt | +- sed --unbuffered -n 's/.*\(family:\)\([[:digit:]]*\).*$/\2/p;q') +- sport=$(grep "type:$e_type," $evt | +- sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q') ++ type=$(grep "type:$e_type," $evt | sed -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q') ++ family=$(grep "type:$e_type," $evt | sed -n 's/.*\(family:\)\([[:digit:]]*\).*$/\2/p;q') ++ sport=$(grep "type:$e_type," $evt | sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q') + if [ $family ] && [ $family = $AF_INET6 ]; then +- saddr=$(grep "type:$e_type," $evt | +- sed --unbuffered -n 's/.*\(saddr6:\)\([0-9a-f:.]*\).*$/\2/p;q') ++ saddr=$(grep "type:$e_type," $evt | sed -n 's/.*\(saddr6:\)\([0-9a-f:.]*\).*$/\2/p;q') + else +- saddr=$(grep "type:$e_type," $evt | +- sed --unbuffered -n 's/.*\(saddr4:\)\([0-9.]*\).*$/\2/p;q') ++ saddr=$(grep "type:$e_type," $evt | sed -n 's/.*\(saddr4:\)\([0-9.]*\).*$/\2/p;q') + fi + + if [ $type ] && [ $type = $e_type ] && + [ $family ] && [ $family = $e_family ] && + [ $saddr ] && [ $saddr = $e_saddr ] && + [ $sport ] && [ $sport = $e_sport ]; then +- stdbuf -o0 -e0 printf "[ ok ]\n" ++ echo "[ ok ]" + return 0 + fi + fail_test +- stdbuf -o0 -e0 printf "[fail]\n" ++ echo "[fail]" + } + + add_addr_ports_tests() diff --git a/queue-6.3/selftests-mptcp-join-use-iptables-legacy-if-available.patch b/queue-6.3/selftests-mptcp-join-use-iptables-legacy-if-available.patch new file mode 100644 index 00000000000..789ec418526 --- /dev/null +++ b/queue-6.3/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 +@@ -146,7 +148,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 +@@ -247,9 +253,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 +@@ -314,9 +320,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 \ +@@ -704,7 +710,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.3/selftests-mptcp-lib-skip-if-missing-symbol.patch b/queue-6.3/selftests-mptcp-lib-skip-if-missing-symbol.patch new file mode 100644 index 00000000000..e055c412bcc --- /dev/null +++ b/queue-6.3/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.3/selftests-mptcp-lib-skip-if-not-below-kernel-version.patch b/queue-6.3/selftests-mptcp-lib-skip-if-not-below-kernel-version.patch new file mode 100644 index 00000000000..eb9568d1a60 --- /dev/null +++ b/queue-6.3/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.3/selftests-mptcp-pm-nl-remove-hardcoded-default-limits.patch b/queue-6.3/selftests-mptcp-pm-nl-remove-hardcoded-default-limits.patch new file mode 100644 index 00000000000..1a617ef053a --- /dev/null +++ b/queue-6.3/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.3/selftests-mptcp-pm-nl-skip-fullmesh-flag-checks-if-not-supported.patch b/queue-6.3/selftests-mptcp-pm-nl-skip-fullmesh-flag-checks-if-not-supported.patch new file mode 100644 index 00000000000..9c23224fbb8 --- /dev/null +++ b/queue-6.3/selftests-mptcp-pm-nl-skip-fullmesh-flag-checks-if-not-supported.patch @@ -0,0 +1,58 @@ +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(-) + +--- 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 (bac + 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 diff --git a/queue-6.3/selftests-mptcp-remove-duplicated-entries-in-usage.patch b/queue-6.3/selftests-mptcp-remove-duplicated-entries-in-usage.patch new file mode 100644 index 00000000000..2e0b55f7c2d --- /dev/null +++ b/queue-6.3/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 +@@ -106,8 +106,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 " +@@ -126,13 +126,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.3/selftests-mptcp-sockopt-relax-expected-returned-size.patch b/queue-6.3/selftests-mptcp-sockopt-relax-expected-returned-size.patch new file mode 100644 index 00000000000..7c0b37516f5 --- /dev/null +++ b/queue-6.3/selftests-mptcp-sockopt-relax-expected-returned-size.patch @@ -0,0 +1,87 @@ +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 +--- + tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +--- 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(struc + 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( + 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); diff --git a/queue-6.3/selftests-mptcp-sockopt-skip-getsockopt-checks-if-not-supported.patch b/queue-6.3/selftests-mptcp-sockopt-skip-getsockopt-checks-if-not-supported.patch new file mode 100644 index 00000000000..61ca53a2bf1 --- /dev/null +++ b/queue-6.3/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 +@@ -87,6 +87,7 @@ cleanup() + } + + mptcp_lib_check_mptcp ++mptcp_lib_check_kallsyms + + ip -Version > /dev/null 2>&1 + if [ $? -ne 0 ];then +@@ -253,6 +254,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.3/selftests-mptcp-sockopt-skip-tcp_inq-checks-if-not-supported.patch b/queue-6.3/selftests-mptcp-sockopt-skip-tcp_inq-checks-if-not-supported.patch new file mode 100644 index 00000000000..15cd6f7e45f --- /dev/null +++ b/queue-6.3/selftests-mptcp-sockopt-skip-tcp_inq-checks-if-not-supported.patch @@ -0,0 +1,68 @@ +From b631e3a4e94c77c9007d60b577a069c203ce9594 Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:53 +0200 +Subject: selftests: mptcp: sockopt: skip TCP_INQ checks if not supported + +From: Matthieu Baerts + +commit b631e3a4e94c77c9007d60b577a069c203ce9594 upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is TCP_INQ cmsg support introduced in commit 2c9e77659a0c +("mptcp: add TCP_INQ cmsg support"). + +It is possible to look for "mptcp_ioctl" in kallsyms because it was +needed to introduce the mentioned feature. We can skip these tests and +not set TCPINQ option if the feature is not supported. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 5cbd886ce2a9 ("selftests: mptcp: add TCP_INQ support") +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 | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +@@ -187,9 +187,14 @@ do_transfer() + local_addr="0.0.0.0" + fi + ++ cmsg="TIMESTAMPNS" ++ if mptcp_lib_kallsyms_has "mptcp_ioctl$"; then ++ cmsg+=",TCPINQ" ++ fi ++ + timeout ${timeout_test} \ + ip netns exec ${listener_ns} \ +- $mptcp_connect -t ${timeout_poll} -l -M 1 -p $port -s ${srv_proto} -c TIMESTAMPNS,TCPINQ \ ++ $mptcp_connect -t ${timeout_poll} -l -M 1 -p $port -s ${srv_proto} -c "${cmsg}" \ + ${local_addr} < "$sin" > "$sout" & + local spid=$! + +@@ -197,7 +202,7 @@ do_transfer() + + timeout ${timeout_test} \ + ip netns exec ${connector_ns} \ +- $mptcp_connect -t ${timeout_poll} -M 2 -p $port -s ${cl_proto} -c TIMESTAMPNS,TCPINQ \ ++ $mptcp_connect -t ${timeout_poll} -M 2 -p $port -s ${cl_proto} -c "${cmsg}" \ + $connect_addr < "$cin" > "$cout" & + + local cpid=$! +@@ -313,6 +318,11 @@ do_tcpinq_tests() + { + local lret=0 + ++ if ! mptcp_lib_kallsyms_has "mptcp_ioctl$"; then ++ echo "INFO: TCP_INQ not supported: SKIP" ++ return ++ fi ++ + local args + for args in "-t tcp" "-r tcp"; do + do_tcpinq_test $args diff --git a/queue-6.3/selftests-mptcp-userspace-pm-skip-if-ip-tool-is-unavailable.patch b/queue-6.3/selftests-mptcp-userspace-pm-skip-if-ip-tool-is-unavailable.patch new file mode 100644 index 00000000000..0fdc34bfb79 --- /dev/null +++ b/queue-6.3/selftests-mptcp-userspace-pm-skip-if-ip-tool-is-unavailable.patch @@ -0,0 +1,33 @@ +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(-) + +--- 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 diff --git a/queue-6.3/selftests-mptcp-userspace-pm-skip-if-not-supported.patch b/queue-6.3/selftests-mptcp-userspace-pm-skip-if-not-supported.patch new file mode 100644 index 00000000000..eaa23d2ee2e --- /dev/null +++ b/queue-6.3/selftests-mptcp-userspace-pm-skip-if-not-supported.patch @@ -0,0 +1,42 @@ +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(+) + +--- 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" diff --git a/queue-6.3/selftests-mptcp-userspace-pm-skip-pm-listener-events-tests-if-unavailable.patch b/queue-6.3/selftests-mptcp-userspace-pm-skip-pm-listener-events-tests-if-unavailable.patch new file mode 100644 index 00000000000..8a71e8feaf3 --- /dev/null +++ b/queue-6.3/selftests-mptcp-userspace-pm-skip-pm-listener-events-tests-if-unavailable.patch @@ -0,0 +1,56 @@ +From 626cb7a5f6b892e48f27a76d11af040c538e03dc Mon Sep 17 00:00:00 2001 +From: Matthieu Baerts +Date: Thu, 8 Jun 2023 18:38:56 +0200 +Subject: selftests: mptcp: userspace pm: skip PM listener events tests if unavailable + +From: Matthieu Baerts + +commit 626cb7a5f6b892e48f27a76d11af040c538e03dc upstream. + +Selftests are supposed to run on any kernels, including the old ones not +supporting all MPTCP features. + +One of them is the new listener events linked to the path-manager +introduced by commit f8c9dfbd875b ("mptcp: add pm listener events"). + +It is possible to look for "mptcp_event_pm_listener" in kallsyms to know +in advance if the kernel supports this feature and skip these sub-tests +if the feature is not supported. + +Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 +Fixes: 6c73008aa301 ("selftests: mptcp: listener test for userspace PM") +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 | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh +index 38a1d34f7b4d..98d9e4d2d3fc 100755 +--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh ++++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh +@@ -4,6 +4,7 @@ + . "$(dirname "${0}")/mptcp_lib.sh" + + mptcp_lib_check_mptcp ++mptcp_lib_check_kallsyms + + if ! mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + echo "userspace pm tests are not supported by the kernel: SKIP" +@@ -914,6 +915,11 @@ test_listener() + { + print_title "Listener tests" + ++ if ! mptcp_lib_kallsyms_has "mptcp_event_pm_listener$"; then ++ stdbuf -o0 -e0 printf "LISTENER events \t[SKIP] Not supported\n" ++ return ++ fi ++ + # Capture events on the network namespace running the client + :>$client_evts + +-- +2.41.0 + diff --git a/queue-6.3/series b/queue-6.3/series index 6aca6765fd9..debb6d06cf0 100644 --- a/queue-6.3/series +++ b/queue-6.3/series @@ -14,3 +14,37 @@ afs-fix-dangling-folio-ref-counts-in-writeback.patch afs-fix-waiting-for-writeback-then-skipping-folio.patch tick-common-align-tick-period-during-sched_timer-setup.patch revert-virtio-blk-support-completion-batching-for-the-irq-path.patch +riscv-link-with-z-norelro.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-connect-skip-tfo-tests-if-not-supported.patch +selftests-mptcp-diag-skip-listen-tests-if-not-supported.patch +selftests-mptcp-diag-skip-inuse-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-sockopt-skip-tcp_inq-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-userspace-pm-skip-pm-listener-events-tests-if-unavailable.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-skip-test-if-iptables-tc-cmds-fail.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-userspace-pm-tests-if-not-supported.patch +selftests-mptcp-join-skip-fail-tests-if-not-supported.patch +selftests-mptcp-join-skip-mpc-backups-tests-if-not-supported.patch +selftests-mptcp-join-skip-pm-listener-tests-if-not-supported.patch +selftests-mptcp-join-uniform-listener-tests.patch +selftests-mptcp-join-skip-mixed-tests-if-not-supported.patch