All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported
@ 2023-05-31 14:16 Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 01/32] selftests: mptcp: lib: skip if missing symbol Matthieu Baerts
                   ` (32 more replies)
  0 siblings, 33 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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

These different patches allow the different MPTCP selftests to be
executed on older kernels.

I tried to minimise the modifications and do the checks from the bash
script not to have to detect the feature when being used in a .c file,
then pass the info to the bash script, skip the test, clean the
environment, etc. As you can see, even with this minimalistic way, a lot
of modifications have been done to support old kernels.

Note that if we expect to have all features available,
SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var can be set to 1 to mark
the tests as failed instead of skipped and track regressions just in
case one of these checks is wrong. The public CI already set this env
var to 1.

This is a big series impacting new development. Probably best to apply
it "quickly" in our tree and fix issues later to avoid multiple rebases.

Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/368
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
Changes in v3:
- Patches 1-7 have been already applied
- check kernel version: new env var that can be set to skip the versions
  check so it works if a new feature is backported to an older kernel.
- get_counter() to get the MIB counters: I can help the stable team with
  the backports that will not be difficult I think but will cause
  conflicts
- check nf/tc issues: looks safer just in case a kconfig is missing or
  an issue with nf/tc but can be removed if you prefer (still I don't
  think we should exit in the middle of a test so I kept it for the
  moment)
- one check per block of tests around the same theme: it would indeed
  avoid re-doing the same check 2 or 3 times but it would break the IDs
  (+maybe less obvious a test might be skipped when reviewing code)
- backports: at the end, we just need all these new checks to be
  backported on the last stable kernel (6.3) because that's what is used
  by the different CIs. It is fine if it is not backported after. (but
  still I can help with the backports, I'm used to :) )
- New patches:
  - selftests: mptcp: join: uniform listener tests
  - Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase"
- See the changelog on the individual patches
- Link to v2: https://lore.kernel.org/r/20230406-mptcp-issue-368-selftests-old-kernels-v2-0-50313e4f83ab@tessares.net

Changes in v2:
- The first patches are almost the same as in v1, the main modifications
  are in mptcp_lib.sh (and in the commit messages): new helpers but also
  the use of SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var.
- Link to v1: https://lore.kernel.org/r/20230406-mptcp-issue-368-selftests-old-kernels-v1-0-246ac567724d@tessares.net

---
Matthieu Baerts (32):
      selftests: mptcp: lib: skip if missing symbol
      selftests: mptcp: lib: skip if not below kernel version
      selftests: mptcp: connect: skip transp tests if not supported
      selftests: mptcp: connect: skip disconnect tests if not supported
      selftests: mptcp: connect: skip TFO tests if not supported
      selftests: mptcp: diag: skip listen tests if not supported
      selftests: mptcp: diag: skip inuse tests if not supported
      selftests: mptcp: pm nl: remove hardcoded default limits
      selftests: mptcp: pm nl: skip fullmesh flag checks if not supported
      selftests: mptcp: sockopt: relax expected returned size
      selftests: mptcp: sockopt: skip getsockopt checks if not supported
      selftests: mptcp: sockopt: skip TCP_INQ checks if not supported
      selftests: mptcp: userspace pm: skip if 'ip' tool is unavailable
      selftests: mptcp: userspace pm: skip if not supported
      selftests: mptcp: userspace pm: skip PM listener events tests if unavailable
      selftests: mptcp: join: use 'iptables-legacy' if available
      selftests: mptcp: join: helpers to skip tests
      selftests: mptcp: join: skip check if MIB counter not supported
      selftests: mptcp: join: skip test if iptables/tc cmds fail
      selftests: mptcp: join: support local endpoint being tracked or not
      selftests: mptcp: join: skip Fastclose tests if not supported
      selftests: mptcp: join: support RM_ADDR for used endpoints or not
      selftests: mptcp: join: skip implicit tests if not supported
      selftests: mptcp: join: skip backup if set flag on ID not supported
      selftests: mptcp: join: skip fullmesh flag tests if not supported
      selftests: mptcp: join: skip userspace PM tests if not supported
      selftests: mptcp: join: skip fail tests if not supported
      selftests: mptcp: join: skip MPC backups tests if not supported
      selftests: mptcp: join: skip PM listener tests if not supported
      selftests: mptcp: join: uniform listener tests
      selftests: mptcp: join: skip mixed tests if not supported
      Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase"

 tools/testing/selftests/net/mptcp/config           |   1 +
 tools/testing/selftests/net/mptcp/diag.sh          |  42 +-
 tools/testing/selftests/net/mptcp/mptcp_connect.sh |  20 +
 tools/testing/selftests/net/mptcp/mptcp_join.sh    | 536 +++++++++++++--------
 tools/testing/selftests/net/mptcp/mptcp_lib.sh     |  64 +++
 tools/testing/selftests/net/mptcp/mptcp_sockopt.c  |  26 +-
 tools/testing/selftests/net/mptcp/mptcp_sockopt.sh |  20 +-
 tools/testing/selftests/net/mptcp/pm_netlink.sh    |  27 +-
 tools/testing/selftests/net/mptcp/userspace_pm.sh  |  13 +-
 9 files changed, 506 insertions(+), 243 deletions(-)
---
base-commit: 3d6d7b1262115b5ccc87b47a61f0a2db3d1b2fbf
change-id: 20230406-mptcp-issue-368-selftests-old-kernels-fffd69d67d91

Best regards,
-- 
Matthieu Baerts <matthieu.baerts@tessares.net>


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 01/32] selftests: mptcp: lib: skip if missing symbol
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 02/32] selftests: mptcp: lib: skip if not below kernel version Matthieu Baerts
                   ` (31 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/config       |  1 +
 tools/testing/selftests/net/mptcp/mptcp_lib.sh | 38 ++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/config b/tools/testing/selftests/net/mptcp/config
index 38021a0dd527..6032f9b23c4c 100644
--- 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
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index 3286536b79d5..29b65f4b73b2 100644
--- 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"
+}

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 02/32] selftests: mptcp: lib: skip if not below kernel version
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 01/32] selftests: mptcp: lib: skip if missing symbol Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 03/32] selftests: mptcp: connect: skip transp tests if not supported Matthieu Baerts
                   ` (30 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
v3:
  - Skip the test if SELFTESTS_MPTCP_LIB_NO_KVERSION_CHECK env var is 1.
---
 tools/testing/selftests/net/mptcp/mptcp_lib.sh | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index 29b65f4b73b2..f32045b23b89 100644
--- 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}"
+}

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 03/32] selftests: mptcp: connect: skip transp tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 01/32] selftests: mptcp: lib: skip if missing symbol Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 02/32] selftests: mptcp: lib: skip if not below kernel version Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 04/32] selftests: mptcp: connect: skip disconnect " Matthieu Baerts
                   ` (29 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
v3:
- s/TFO/${msg}/ in the INFO message
---
 tools/testing/selftests/net/mptcp/mptcp_connect.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index c1f7bac19942..f9c36c6929cc 100755
--- 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 {

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 04/32] selftests: mptcp: connect: skip disconnect tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (2 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 03/32] selftests: mptcp: connect: skip transp tests if not supported Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 05/32] selftests: mptcp: connect: skip TFO " Matthieu Baerts
                   ` (28 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index f9c36c6929cc..895114fb6832 100755
--- 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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 05/32] selftests: mptcp: connect: skip TFO tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (3 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 04/32] selftests: mptcp: connect: skip disconnect " Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 06/32] selftests: mptcp: diag: skip listen " Matthieu Baerts
                   ` (27 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index 895114fb6832..773dd770a567 100755
--- 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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 06/32] selftests: mptcp: diag: skip listen tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (4 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 05/32] selftests: mptcp: connect: skip TFO " Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 07/32] selftests: mptcp: diag: skip inuse " Matthieu Baerts
                   ` (26 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/diag.sh | 42 +++++++++++++------------------
 1 file changed, 17 insertions(+), 25 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
index 4eacdb1ab962..4a6165389b74 100755
--- 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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 07/32] selftests: mptcp: diag: skip inuse tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (5 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 06/32] selftests: mptcp: diag: skip listen " Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 08/32] selftests: mptcp: pm nl: remove hardcoded default limits Matthieu Baerts
                   ` (25 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 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.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 08/32] selftests: mptcp: pm nl: remove hardcoded default limits
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (6 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 07/32] selftests: mptcp: diag: skip inuse " Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 09/32] selftests: mptcp: pm nl: skip fullmesh flag checks if not supported Matthieu Baerts
                   ` (24 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/pm_netlink.sh | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 32f7533e0919..664cafc60705 100755
--- 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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 09/32] selftests: mptcp: pm nl: skip fullmesh flag checks if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (7 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 08/32] selftests: mptcp: pm nl: remove hardcoded default limits Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 10/32] selftests: mptcp: sockopt: relax expected returned size Matthieu Baerts
                   ` (23 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/pm_netlink.sh | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 664cafc60705..d02e0d63a8f9 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -178,14 +178,19 @@ subflow,backup 10.0.1.1" "set flags (backup)"
 ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags nobackup
 check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
 subflow 10.0.1.1" "          (nobackup)"
+
+# fullmesh support has been added later
 ip netns exec $ns1 ./pm_nl_ctl set id 1 flags fullmesh
-check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
+if ip netns exec $ns1 ./pm_nl_ctl dump | grep -q "fullmesh" ||
+   mptcp_lib_expect_all_features; then
+	check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
 subflow,fullmesh 10.0.1.1" "          (fullmesh)"
-ip netns exec $ns1 ./pm_nl_ctl set id 1 flags nofullmesh
-check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
+	ip netns exec $ns1 ./pm_nl_ctl set id 1 flags nofullmesh
+	check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
 subflow 10.0.1.1" "          (nofullmesh)"
-ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh
-check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
+	ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh
+	check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
 subflow,backup,fullmesh 10.0.1.1" "          (backup,fullmesh)"
+fi
 
 exit $ret

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 10/32] selftests: mptcp: sockopt: relax expected returned size
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (8 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 09/32] selftests: mptcp: pm nl: skip fullmesh flag checks if not supported Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 11/32] selftests: mptcp: sockopt: skip getsockopt checks if not supported Matthieu Baerts
                   ` (22 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
v3:
  - size_user: check if it is the min between the user and kernel sizes
---
 tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index 86a378731e8b..de897f77e174 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -123,6 +123,8 @@ struct so_state {
 	bool pkt_stats_avail;
 };
 
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+
 static void die_perror(const char *msg)
 {
 	perror(msg);
@@ -386,13 +388,14 @@ static void do_getsockopt_tcp_info(struct so_state *s, int fd, size_t r, size_t
 			xerror("getsockopt MPTCP_TCPINFO (tries %d, %m)");
 
 		assert(olen <= sizeof(ti));
-		assert(ti.d.size_user == ti.d.size_kernel);
-		assert(ti.d.size_user == sizeof(struct tcp_info));
+		assert(ti.d.size_kernel > 0);
+		assert(ti.d.size_user ==
+		       MIN(ti.d.size_kernel, sizeof(struct tcp_info)));
 		assert(ti.d.num_subflows == 1);
 
 		assert(olen > (socklen_t)sizeof(struct mptcp_subflow_data));
 		olen -= sizeof(struct mptcp_subflow_data);
-		assert(olen == sizeof(struct tcp_info));
+		assert(olen == ti.d.size_user);
 
 		s->tcp_info = ti.ti[0];
 
@@ -440,13 +443,14 @@ static void do_getsockopt_subflow_addrs(struct so_state *s, int fd)
 		die_perror("getsockopt MPTCP_SUBFLOW_ADDRS");
 
 	assert(olen <= sizeof(addrs));
-	assert(addrs.d.size_user == addrs.d.size_kernel);
-	assert(addrs.d.size_user == sizeof(struct mptcp_subflow_addrs));
+	assert(addrs.d.size_kernel > 0);
+	assert(addrs.d.size_user ==
+	       MIN(addrs.d.size_kernel, sizeof(struct mptcp_subflow_addrs)));
 	assert(addrs.d.num_subflows == 1);
 
 	assert(olen > (socklen_t)sizeof(struct mptcp_subflow_data));
 	olen -= sizeof(struct mptcp_subflow_data);
-	assert(olen == sizeof(struct mptcp_subflow_addrs));
+	assert(olen == addrs.d.size_user);
 
 	llen = sizeof(local);
 	ret = getsockname(fd, (struct sockaddr *)&local, &llen);

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 11/32] selftests: mptcp: sockopt: skip getsockopt checks if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (9 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 10/32] selftests: mptcp: sockopt: relax expected returned size Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 12/32] selftests: mptcp: sockopt: skip TCP_INQ " Matthieu Baerts
                   ` (21 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index ff5adbb9c7f2..1d4ae8792227 100755
--- 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=$?
 

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 12/32] selftests: mptcp: sockopt: skip TCP_INQ checks if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (10 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 11/32] selftests: mptcp: sockopt: skip getsockopt checks if not supported Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 13/32] selftests: mptcp: userspace pm: skip if 'ip' tool is unavailable Matthieu Baerts
                   ` (20 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index 1d4ae8792227..f295a371ff14 100755
--- 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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 13/32] selftests: mptcp: userspace pm: skip if 'ip' tool is unavailable
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (11 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 12/32] selftests: mptcp: sockopt: skip TCP_INQ " Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 14/32] selftests: mptcp: userspace pm: skip if not supported Matthieu Baerts
                   ` (19 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/userspace_pm.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
index 8092399d911f..192ab818f292 100755
--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
+++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
@@ -8,7 +8,7 @@ mptcp_lib_check_mptcp
 ip -Version > /dev/null 2>&1
 if [ $? -ne 0 ];then
 	echo "SKIP: Cannot not run test without ip tool"
-	exit 1
+	exit ${KSFT_SKIP}
 fi
 
 ANNOUNCED=6        # MPTCP_EVENT_ANNOUNCED

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 14/32] selftests: mptcp: userspace pm: skip if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (12 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 13/32] selftests: mptcp: userspace pm: skip if 'ip' tool is unavailable Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 15/32] selftests: mptcp: userspace pm: skip PM listener events tests if unavailable Matthieu Baerts
                   ` (18 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/userspace_pm.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
index 192ab818f292..38a1d34f7b4d 100755
--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
+++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
@@ -5,6 +5,11 @@
 
 mptcp_lib_check_mptcp
 
+if ! mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
+	echo "userspace pm tests are not supported by the kernel: SKIP"
+	exit ${KSFT_SKIP}
+fi
+
 ip -Version > /dev/null 2>&1
 if [ $? -ne 0 ];then
 	echo "SKIP: Cannot not run test without ip tool"

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 15/32] selftests: mptcp: userspace pm: skip PM listener events tests if unavailable
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (13 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 14/32] selftests: mptcp: userspace pm: skip if not supported Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 16/32] selftests: mptcp: join: use 'iptables-legacy' if available Matthieu Baerts
                   ` (17 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 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.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 16/32] selftests: mptcp: join: use 'iptables-legacy' if available
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (14 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 15/32] selftests: mptcp: userspace pm: skip PM listener events tests if unavailable Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 17/32] selftests: mptcp: join: helpers to skip tests Matthieu Baerts
                   ` (16 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 85474e029784..4dc529d95da4 100755
--- 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
@@ -148,7 +150,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
@@ -249,9 +255,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
@@ -316,9 +322,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 \
@@ -709,7 +715,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()

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 17/32] selftests: mptcp: join: helpers to skip tests
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (15 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 16/32] selftests: mptcp: join: use 'iptables-legacy' if available Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 18/32] selftests: mptcp: join: skip check if MIB counter not supported Matthieu Baerts
                   ` (15 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 27 +++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 4dc529d95da4..72bc6769c184 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -144,6 +144,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"
@@ -193,6 +194,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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 18/32] selftests: mptcp: join: skip check if MIB counter not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (16 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 17/32] selftests: mptcp: join: helpers to skip tests Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 19/32] selftests: mptcp: join: skip test if iptables/tc cmds fail Matthieu Baerts
                   ` (14 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
v3:
  - Add more info about what the new helper does + backports note
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 251 ++++++++++++++----------
 1 file changed, 142 insertions(+), 109 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 72bc6769c184..53178ef00b50 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -505,11 +505,25 @@ wait_local_port_listen()
 	done
 }
 
+# $1: ns ; $2: counter
+get_counter()
+{
+	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
+
+	echo "${count}"
+}
+
 rm_addr_count()
 {
-	local ns=${1}
-
-	ip netns exec ${ns} nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'
+	get_counter "${1}" "MPTcpExtRmAddr"
 }
 
 # $1: ns, $2: old rm_addr counter in $ns
@@ -532,11 +546,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
@@ -1194,12 +1208,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
@@ -1207,12 +1222,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
@@ -1265,12 +1282,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
@@ -1298,10 +1316,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
 	else
@@ -1309,10 +1328,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
 	else
@@ -1339,9 +1359,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
 	else
@@ -1349,9 +1370,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
 	else
@@ -1368,9 +1390,10 @@ chk_infi_nr()
 	local count
 
 	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
 	else
@@ -1378,9 +1401,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
 	else
@@ -1408,9 +1432,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
 	else
@@ -1419,9 +1444,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
@@ -1436,9 +1462,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
 	else
@@ -1468,12 +1495,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], " \
@@ -1508,12 +1535,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
 	else
@@ -1521,9 +1548,10 @@ chk_add_nr()
 	fi
 
 	echo -n " - echo  "
-	count=$(ip netns exec $ns1 nstat -as MPTcpExtEchoAdd | 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
 	else
@@ -1532,9 +1560,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
 		else
@@ -1542,10 +1571,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
@@ -1554,10 +1583,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
@@ -1566,10 +1595,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
@@ -1578,10 +1607,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
@@ -1590,10 +1619,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
@@ -1615,12 +1644,12 @@ chk_add_tx_nr()
 	timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout)
 
 	printf "%-${nr_blank}s %s" " " "add TX"
-	count=$(ip netns exec $ns1 nstat -as MPTcpExtAddAddrTx | grep MPTcpExtAddAddrTx | awk '{print $2}')
-	[ -z "$count" ] && count=0
-
+	count=$(get_counter ${ns1} "MPTcpExtAddAddrTx")
+	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_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then
+	elif [ "$count" != "$add_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then
 		echo "[fail] got $count ADD_ADDR[s] TX, expected $add_tx_nr"
 		fail_test
 	else
@@ -1628,9 +1657,10 @@ chk_add_tx_nr()
 	fi
 
 	echo -n " - echo TX "
-	count=$(ip netns exec $ns2 nstat -as MPTcpExtEchoAddTx | grep MPTcpExtEchoAddTx | awk '{print $2}')
-	[ -z "$count" ] && count=0
-	if [ "$count" != "$echo_tx_nr" ]; then
+	count=$(get_counter ${ns2} "MPTcpExtEchoAddTx")
+	if [ -z "$count" ]; then
+		echo "[skip]"
+	elif [ "$count" != "$echo_tx_nr" ]; then
 		echo "[fail] got $count ADD_ADDR echo[s] TX, expected $echo_tx_nr"
 		fail_test
 	else
@@ -1666,9 +1696,10 @@ chk_rm_nr()
 	fi
 
 	printf "%-${nr_blank}s %s" " " "rm "
-	count=$(ip netns exec $addr_ns nstat -as MPTcpExtRmAddr | 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
 	else
@@ -1676,12 +1707,13 @@ 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
@@ -1690,14 +1722,12 @@ chk_rm_nr()
 		[ "$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
 		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
 	else
@@ -1712,9 +1742,10 @@ chk_rm_tx_nr()
 	local rm_addr_tx_nr=$1
 
 	printf "%-${nr_blank}s %s" " " "rm TX "
-	count=$(ip netns exec $ns2 nstat -as MPTcpExtRmAddrTx | grep MPTcpExtRmAddrTx | awk '{print $2}')
-	[ -z "$count" ] && count=0
-	if [ "$count" != "$rm_addr_tx_nr" ]; then
+	count=$(get_counter ${ns2} "MPTcpExtRmAddrTx")
+	if [ -z "$count" ]; then
+		echo -n "[skip]"
+	elif [ "$count" != "$rm_addr_tx_nr" ]; then
 		echo "[fail] got $count RM_ADDR[s] expected $rm_addr_tx_nr"
 		fail_test
 	else
@@ -1731,9 +1762,10 @@ chk_prio_nr()
 	local count
 
 	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
 	else
@@ -1741,9 +1773,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
 	else
@@ -1854,7 +1887,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))

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 19/32] selftests: mptcp: join: skip test if iptables/tc cmds fail
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (17 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 18/32] selftests: mptcp: join: skip check if MIB counter not supported Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 20/32] selftests: mptcp: join: support local endpoint being tracked or not Matthieu Baerts
                   ` (13 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
v3:
  - add a note about the missing kconfig and the exit
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 88 ++++++++++++++++---------
 1 file changed, 57 insertions(+), 31 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 53178ef00b50..31b7d04a4e1e 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -288,11 +288,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
@@ -336,17 +340,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}"
@@ -361,15 +360,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()
@@ -384,6 +400,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
@@ -750,15 +785,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"
@@ -1980,23 +2006,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
@@ -2004,11 +2030,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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 20/32] selftests: mptcp: join: support local endpoint being tracked or not
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (18 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 19/32] selftests: mptcp: join: skip test if iptables/tc cmds fail Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 21/32] selftests: mptcp: join: skip Fastclose tests if not supported Matthieu Baerts
                   ` (12 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 31b7d04a4e1e..443a186e536a 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2135,11 +2135,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
 }
 

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 21/32] selftests: mptcp: join: skip Fastclose tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (19 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 20/32] selftests: mptcp: join: support local endpoint being tracked or not Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 22/32] selftests: mptcp: join: support RM_ADDR for used endpoints or not Matthieu Baerts
                   ` (11 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 443a186e536a..a2455d0e2abe 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -263,6 +263,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()
 {
@@ -3130,14 +3143,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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 22/32] selftests: mptcp: join: support RM_ADDR for used endpoints or not
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (20 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 21/32] selftests: mptcp: join: skip Fastclose tests if not supported Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 23/32] selftests: mptcp: join: skip implicit tests if not supported Matthieu Baerts
                   ` (10 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index a2455d0e2abe..d07d448059b8 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2402,8 +2402,13 @@ 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_tx_nr 0
-		chk_rm_nr 0 3 simult
+
+		if mptcp_lib_kversion_ge 5.18; then
+			chk_rm_tx_nr 0
+			chk_rm_nr 0 3 simult
+		else
+			chk_rm_nr 3 3
+		fi
 	fi
 
 	# addresses flush

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 23/32] selftests: mptcp: join: skip implicit tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (21 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 22/32] selftests: mptcp: join: support RM_ADDR for used endpoints or not Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 24/32] selftests: mptcp: join: skip backup if set flag on ID " Matthieu Baerts
                   ` (9 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
v3:
  - Note about not skipping the whole function
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index d07d448059b8..d02f715feb62 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -3281,8 +3281,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
@@ -3302,7 +3304,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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 24/32] selftests: mptcp: join: skip backup if set flag on ID not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (22 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 23/32] selftests: mptcp: join: skip implicit tests if not supported Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 25/32] selftests: mptcp: join: skip fullmesh flag tests if " Matthieu Baerts
                   ` (8 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Fixes: 4cf86ae84c71 ("mptcp: strict local address ID selection")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index d02f715feb62..529c95cf7fd3 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2688,7 +2688,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
@@ -2698,7 +2699,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
@@ -2709,7 +2711,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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 25/32] selftests: mptcp: join: skip fullmesh flag tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (23 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 24/32] selftests: mptcp: join: skip backup if set flag on ID " Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 26/32] selftests: mptcp: join: skip userspace PM " Matthieu Baerts
                   ` (7 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 529c95cf7fd3..04464a73ac9d 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -3107,7 +3107,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
@@ -3117,7 +3118,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
@@ -3127,7 +3129,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
@@ -3138,7 +3141,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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 26/32] selftests: mptcp: join: skip userspace PM tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (24 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 25/32] selftests: mptcp: join: skip fullmesh flag tests if " Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 27/32] selftests: mptcp: join: skip fail " Matthieu Baerts
                   ` (6 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 26 ++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 04464a73ac9d..9c7b620a5c12 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -85,7 +85,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
@@ -3200,7 +3200,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
@@ -3211,7 +3212,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
@@ -3222,7 +3224,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
@@ -3232,7 +3235,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
@@ -3242,7 +3246,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
@@ -3253,7 +3258,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
@@ -3265,7 +3271,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
@@ -3276,7 +3283,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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 27/32] selftests: mptcp: join: skip fail tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (25 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 26/32] selftests: mptcp: join: skip userspace PM " Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 28/32] selftests: mptcp: join: skip MPC backups " Matthieu Baerts
                   ` (5 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Fixes: 2ba18161d407 ("selftests: mptcp: add MP_FAIL reset testcase")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 9c7b620a5c12..0ad8cce088d8 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -386,7 +386,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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 28/32] selftests: mptcp: join: skip MPC backups tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (26 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 27/32] selftests: mptcp: join: skip fail " Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 29/32] selftests: mptcp: join: skip PM listener " Matthieu Baerts
                   ` (4 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 0ad8cce088d8..82281d59ac10 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2722,14 +2722,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
@@ -2737,14 +2739,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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 29/32] selftests: mptcp: join: skip PM listener tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (27 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 28/32] selftests: mptcp: join: skip MPC backups " Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 30/32] selftests: mptcp: join: uniform listener tests Matthieu Baerts
                   ` (3 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 82281d59ac10..9d6c4c1ecff1 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2783,6 +2783,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 |

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 30/32] selftests: mptcp: join: uniform listener tests
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (28 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 29/32] selftests: mptcp: join: skip PM listener " Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 31/32] selftests: mptcp: join: skip mixed tests if not supported Matthieu Baerts
                   ` (2 subsequent siblings)
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
v3:
  - new patch, initially to fix the alignment but while at it
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 30 ++++++++++++-------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 9d6c4c1ecff1..26721ed7b797 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2774,43 +2774,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()

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 31/32] selftests: mptcp: join: skip mixed tests if not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (29 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 30/32] selftests: mptcp: join: uniform listener tests Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 14:16 ` [PATCH mptcp-net v3 32/32] Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase" Matthieu Baerts
  2023-06-07  9:47 ` [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

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")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 26721ed7b797..2652640be323 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2646,7 +2646,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
@@ -2655,7 +2656,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
@@ -2664,7 +2666,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
@@ -2675,7 +2678,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

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH mptcp-net v3 32/32] Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase"
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (30 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 31/32] selftests: mptcp: join: skip mixed tests if not supported Matthieu Baerts
@ 2023-05-31 14:16 ` Matthieu Baerts
  2023-05-31 15:44   ` Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase": Tests Results MPTCP CI
  2023-06-07  9:47 ` [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
  32 siblings, 1 reply; 35+ messages in thread
From: Matthieu Baerts @ 2023-05-31 14:16 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni, Matthieu Baerts

Relax the expected returned sizes from a getsockopt(MPTCP_FULL_INFO):
the sizes should be positive and the user one should be the min between
the one given by the userspace and the one from the kernelspace.

By doing that, we support new fields added on the userspace or the
kernelspace sides.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
v3:
  - new patch (the mentioned patch has been sent and applied while the
    v2 was still in review)
---
 tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index de897f77e174..5994a078a65d 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -519,10 +519,12 @@ static void do_getsockopt_mptcp_full_info(struct so_state *s, int fd)
 	}
 
 	assert(olen <= data_size);
-	assert(mfi.size_tcpinfo_user == mfi.size_tcpinfo_kernel);
-	assert(mfi.size_tcpinfo_user == sizeof(struct tcp_info));
-	assert(mfi.size_sfinfo_user == mfi.size_sfinfo_kernel);
-	assert(mfi.size_sfinfo_user == sizeof(struct mptcp_subflow_info));
+	assert(mfi.size_tcpinfo_kernel > 0);
+	assert(mfi.size_tcpinfo_user ==
+	       MIN(mfi.size_tcpinfo_kernel, sizeof(struct tcp_info)));
+	assert(mfi.size_sfinfo_kernel > 0);
+	assert(mfi.size_sfinfo_user ==
+	       MIN(mfi.size_sfinfo_kernel, sizeof(struct mptcp_subflow_info)));
 	assert(mfi.num_subflows == 1);
 
 	/* Tolerate future extension to mptcp_info struct and running newer

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase": Tests Results
  2023-05-31 14:16 ` [PATCH mptcp-net v3 32/32] Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase" Matthieu Baerts
@ 2023-05-31 15:44   ` MPTCP CI
  0 siblings, 0 replies; 35+ messages in thread
From: MPTCP CI @ 2023-05-31 15:44 UTC (permalink / raw)
  To: Matthieu Baerts; +Cc: mptcp

Hi Matthieu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join):
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/6481418017046528
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/6481418017046528/summary/summary.txt

- KVM Validation: normal (only selftest_mptcp_join):
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/4651830668427264
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/4651830668427264/summary/summary.txt

- KVM Validation: debug (only selftest_mptcp_join):
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/5214780621848576
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5214780621848576/summary/summary.txt

- KVM Validation: debug (except selftest_mptcp_join):
  - Unstable: 3 failed test(s): packetdrill_add_addr packetdrill_fastopen selftest_diag 🔴:
  - Task: https://cirrus-ci.com/task/5777730575269888
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5777730575269888/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/8702aa095b78


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-debug

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported
  2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (31 preceding siblings ...)
  2023-05-31 14:16 ` [PATCH mptcp-net v3 32/32] Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase" Matthieu Baerts
@ 2023-06-07  9:47 ` Matthieu Baerts
  32 siblings, 0 replies; 35+ messages in thread
From: Matthieu Baerts @ 2023-06-07  9:47 UTC (permalink / raw)
  To: mptcp; +Cc: Paolo Abeni

Hello,

On 31/05/2023 16:16, Matthieu Baerts wrote:
> Selftests are supposed to run on any kernels, including the old ones not
> supporting all MPTCP features.
> 
> These different patches allow the different MPTCP selftests to be
> executed on older kernels.
> 
> I tried to minimise the modifications and do the checks from the bash
> script not to have to detect the feature when being used in a .c file,
> then pass the info to the bash script, skip the test, clean the
> environment, etc. As you can see, even with this minimalistic way, a lot
> of modifications have been done to support old kernels.
> 
> Note that if we expect to have all features available,
> SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var can be set to 1 to mark
> the tests as failed instead of skipped and track regressions just in
> case one of these checks is wrong. The public CI already set this env
> var to 1.
> 
> This is a big series impacting new development. Probably best to apply
> it "quickly" in our tree and fix issues later to avoid multiple rebases.
> 
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/368
> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> ---
> Changes in v3:
> - Patches 1-7 have been already applied
> - check kernel version: new env var that can be set to skip the versions
>   check so it works if a new feature is backported to an older kernel.
> - get_counter() to get the MIB counters: I can help the stable team with
>   the backports that will not be difficult I think but will cause
>   conflicts
> - check nf/tc issues: looks safer just in case a kconfig is missing or
>   an issue with nf/tc but can be removed if you prefer (still I don't
>   think we should exit in the middle of a test so I kept it for the
>   moment)
> - one check per block of tests around the same theme: it would indeed
>   avoid re-doing the same check 2 or 3 times but it would break the IDs
>   (+maybe less obvious a test might be skipped when reviewing code)
> - backports: at the end, we just need all these new checks to be
>   backported on the last stable kernel (6.3) because that's what is used
>   by the different CIs. It is fine if it is not backported after. (but
>   still I can help with the backports, I'm used to :) )
> - New patches:
>   - selftests: mptcp: join: uniform listener tests
>   - Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase"
> - See the changelog on the individual patches
> - Link to v2: https://lore.kernel.org/r/20230406-mptcp-issue-368-selftests-old-kernels-v2-0-50313e4f83ab@tessares.net

As discussed at the last weekly meeting, I just applied this series
(without any extra ACK/RvB for the moment, I can always add some later
if needed). Note that there is a conflict between net and net-next:

- a73cbdf0325c: conflict in top-bases/t/DO-NOT-MERGE-git-markup-net-next

I will make sure we pass the information to netdev maintainers when we
will send these patches to netdev for -net.


Applied in our tree (fix for -net + 1 fix for net-next and a squash-to
patch, see below):

New patches for t/upstream-net and t/upstream:
- c8230ff8c611: selftests: mptcp: lib: skip if missing symbol
- d5b45288feab: selftests: mptcp: lib: skip if not below kernel version
- 13c09048a8a9: selftests: mptcp: connect: skip transp tests if not
supported
- da3fbb1c9d55: selftests: mptcp: connect: skip disconnect tests if not
supported
- 17fd0d99c269: selftests: mptcp: connect: skip TFO tests if not supported
- 56f59ccac581: selftests: mptcp: diag: skip listen tests if not supported
- dc15a4faa5d2: selftests: mptcp: diag: skip inuse tests if not supported
- 0a0aedc21e62: selftests: mptcp: pm nl: remove hardcoded default limits
- a4f952fdfd0d: selftests: mptcp: pm nl: skip fullmesh flag checks if
not supported
- c9e5532bbb9a: selftests: mptcp: sockopt: relax expected returned size
- 119bd6b5574d: selftests: mptcp: sockopt: skip getsockopt checks if not
supported
- 5057b6fd18b4: selftests: mptcp: sockopt: skip TCP_INQ checks if not
supported
- b83b318c8d6a: selftests: mptcp: userspace pm: skip if 'ip' tool is
unavailable
- fae0ec9a5799: selftests: mptcp: userspace pm: skip if not supported
- c8763f8313c2: selftests: mptcp: userspace pm: skip PM listener events
tests if unavailable
- 96914defcb81: selftests: mptcp: join: use 'iptables-legacy' if available
- 67a7d697e202: selftests: mptcp: join: helpers to skip tests
- 8bf1ea244e7a: selftests: mptcp: join: skip check if MIB counter not
supported
- da5bce0ddee8: selftests: mptcp: join: skip test if iptables/tc cmds fail
- 5ce49553bff9: selftests: mptcp: join: support local endpoint being
tracked or not
- caa512715f88: selftests: mptcp: join: skip Fastclose tests if not
supported
- 66a74fd06d9e: selftests: mptcp: join: support RM_ADDR for used
endpoints or not
- de48230c2cc5: selftests: mptcp: join: skip implicit tests if not supported
- f17f007808ad: selftests: mptcp: join: skip backup if set flag on ID
not supported
- 4b6f29b3fdee: selftests: mptcp: join: skip fullmesh flag tests if not
supported
- 14545e86df1e: selftests: mptcp: join: skip userspace PM tests if not
supported
- 4085b667634e: selftests: mptcp: join: skip fail tests if not supported
- 93c1d1a9c615: selftests: mptcp: join: skip MPC backups tests if not
supported
- d42fc1b70fb7: selftests: mptcp: join: skip PM listener tests if not
supported
- 8b438e39bbee: selftests: mptcp: join: uniform listener tests
- 356b01bcdc41: selftests: mptcp: join: skip mixed tests if not supported
- 426c2b289431: "squashed" patch 32/32 in "selftests: mptcp: add
MPTCP_FULL_INFO testcase"
- Results: 551314e25c6e..4865fe6804ff (export-net)
- a17f99898f8a: selftests: mptcp: join: skip check if MIB counter not
supported (part 2)
- Results: 81bf7db050d7..7aa34a6db848 (export)

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export-net/20230607T094539
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20230607T094151

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2023-06-07  9:47 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31 14:16 [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 01/32] selftests: mptcp: lib: skip if missing symbol Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 02/32] selftests: mptcp: lib: skip if not below kernel version Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 03/32] selftests: mptcp: connect: skip transp tests if not supported Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 04/32] selftests: mptcp: connect: skip disconnect " Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 05/32] selftests: mptcp: connect: skip TFO " Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 06/32] selftests: mptcp: diag: skip listen " Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 07/32] selftests: mptcp: diag: skip inuse " Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 08/32] selftests: mptcp: pm nl: remove hardcoded default limits Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 09/32] selftests: mptcp: pm nl: skip fullmesh flag checks if not supported Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 10/32] selftests: mptcp: sockopt: relax expected returned size Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 11/32] selftests: mptcp: sockopt: skip getsockopt checks if not supported Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 12/32] selftests: mptcp: sockopt: skip TCP_INQ " Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 13/32] selftests: mptcp: userspace pm: skip if 'ip' tool is unavailable Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 14/32] selftests: mptcp: userspace pm: skip if not supported Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 15/32] selftests: mptcp: userspace pm: skip PM listener events tests if unavailable Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 16/32] selftests: mptcp: join: use 'iptables-legacy' if available Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 17/32] selftests: mptcp: join: helpers to skip tests Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 18/32] selftests: mptcp: join: skip check if MIB counter not supported Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 19/32] selftests: mptcp: join: skip test if iptables/tc cmds fail Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 20/32] selftests: mptcp: join: support local endpoint being tracked or not Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 21/32] selftests: mptcp: join: skip Fastclose tests if not supported Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 22/32] selftests: mptcp: join: support RM_ADDR for used endpoints or not Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 23/32] selftests: mptcp: join: skip implicit tests if not supported Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 24/32] selftests: mptcp: join: skip backup if set flag on ID " Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 25/32] selftests: mptcp: join: skip fullmesh flag tests if " Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 26/32] selftests: mptcp: join: skip userspace PM " Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 27/32] selftests: mptcp: join: skip fail " Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 28/32] selftests: mptcp: join: skip MPC backups " Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 29/32] selftests: mptcp: join: skip PM listener " Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 30/32] selftests: mptcp: join: uniform listener tests Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 31/32] selftests: mptcp: join: skip mixed tests if not supported Matthieu Baerts
2023-05-31 14:16 ` [PATCH mptcp-net v3 32/32] Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase" Matthieu Baerts
2023-05-31 15:44   ` Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase": Tests Results MPTCP CI
2023-06-07  9:47 ` [PATCH mptcp-net v3 00/32] selftests: mptcp: skip tests when features are not supported Matthieu Baerts

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.