All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported
@ 2023-05-22 16:37 Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 01/37] selftests: mptcp: connect: skip if MPTCP is " Matthieu Baerts
                   ` (37 more replies)
  0 siblings, 38 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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 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 (37):
      selftests: mptcp: connect: skip if MPTCP is not supported
      selftests: mptcp: pm nl: skip if MPTCP is not supported
      selftests: mptcp: join: skip if MPTCP is not supported
      selftests: mptcp: diag: skip if MPTCP is not supported
      selftests: mptcp: simult flows: skip if MPTCP is not supported
      selftests: mptcp: sockopt: skip if MPTCP is not supported
      selftests: mptcp: userspace pm: skip if MPTCP is not supported
      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: skip mixed tests if not supported

 tools/testing/selftests/net/mptcp/Makefile         |   2 +-
 tools/testing/selftests/net/mptcp/config           |   1 +
 tools/testing/selftests/net/mptcp/diag.sh          |  46 +-
 tools/testing/selftests/net/mptcp/mptcp_connect.sh |  24 +
 tools/testing/selftests/net/mptcp/mptcp_join.sh    | 510 +++++++++++++--------
 tools/testing/selftests/net/mptcp/mptcp_lib.sh     |  99 ++++
 tools/testing/selftests/net/mptcp/mptcp_sockopt.c  |  12 +-
 tools/testing/selftests/net/mptcp/mptcp_sockopt.sh |  24 +-
 tools/testing/selftests/net/mptcp/pm_netlink.sh    |  31 +-
 tools/testing/selftests/net/mptcp/simult_flows.sh  |   4 +
 tools/testing/selftests/net/mptcp/userspace_pm.sh  |  17 +-
 11 files changed, 546 insertions(+), 224 deletions(-)
---
base-commit: 194dd0efe579cb5d3a746d248b3476f4b3fc0b48
change-id: 20230406-mptcp-issue-368-selftests-old-kernels-fffd69d67d91

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


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

* [PATCH mptcp-net v2 01/37] selftests: mptcp: connect: skip if MPTCP is not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 02/37] selftests: mptcp: pm nl: " Matthieu Baerts
                   ` (36 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts

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

A new check is then added to make sure MPTCP is supported. If not, the
test stops and is marked as "skipped". Note that this check can also
mark the test as failed if 'SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES' env
var is set to 1: by doing that, we can make sure a test is not being
skipped by mistake.

A new shared file is added here to be able to re-used the same check in
the different selftests we have.

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/Makefile         |  2 +-
 tools/testing/selftests/net/mptcp/mptcp_connect.sh |  4 +++
 tools/testing/selftests/net/mptcp/mptcp_lib.sh     | 40 ++++++++++++++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
index 43a723626126..7b936a926859 100644
--- a/tools/testing/selftests/net/mptcp/Makefile
+++ b/tools/testing/selftests/net/mptcp/Makefile
@@ -9,7 +9,7 @@ TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \
 
 TEST_GEN_FILES = mptcp_connect pm_nl_ctl mptcp_sockopt mptcp_inq
 
-TEST_FILES := settings
+TEST_FILES := mptcp_lib.sh settings
 
 EXTRA_CLEAN := *.pcap
 
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index a43d3e2f59bb..c1f7bac19942 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -1,6 +1,8 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
+. "$(dirname "${0}")/mptcp_lib.sh"
+
 time_start=$(date +%s)
 
 optstring="S:R:d:e:l:r:h4cm:f:tC"
@@ -141,6 +143,8 @@ cleanup()
 	done
 }
 
+mptcp_lib_check_mptcp
+
 ip -Version > /dev/null 2>&1
 if [ $? -ne 0 ];then
 	echo "SKIP: Could not run test without ip tool"
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
new file mode 100644
index 000000000000..3286536b79d5
--- /dev/null
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -0,0 +1,40 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+readonly KSFT_FAIL=1
+readonly KSFT_SKIP=4
+
+# SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var can be set when validating all
+# features using the last version of the kernel and the selftests to make sure
+# a test is not being skipped by mistake.
+mptcp_lib_expect_all_features() {
+	[ "${SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES:-}" = "1" ]
+}
+
+# $1: msg
+mptcp_lib_fail_if_expected_feature() {
+	if mptcp_lib_expect_all_features; then
+		echo "ERROR: missing feature: ${*}"
+		exit ${KSFT_FAIL}
+	fi
+
+	return 1
+}
+
+# $1: file
+mptcp_lib_has_file() {
+	local f="${1}"
+
+	if [ -f "${f}" ]; then
+		return 0
+	fi
+
+	mptcp_lib_fail_if_expected_feature "${f} file not found"
+}
+
+mptcp_lib_check_mptcp() {
+	if ! mptcp_lib_has_file "/proc/sys/net/mptcp/enabled"; then
+		echo "SKIP: MPTCP support is not available"
+		exit ${KSFT_SKIP}
+	fi
+}

-- 
2.39.2


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

* [PATCH mptcp-net v2 02/37] selftests: mptcp: pm nl: skip if MPTCP is not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 01/37] selftests: mptcp: connect: skip if MPTCP is " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 03/37] selftests: mptcp: join: " Matthieu Baerts
                   ` (35 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts

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

A new check is then added to make sure MPTCP is supported. If not, the
test stops and is marked as "skipped".

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 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 89839d1ff9d8..32f7533e0919 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -1,6 +1,8 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
+. "$(dirname "${0}")/mptcp_lib.sh"
+
 ksft_skip=4
 ret=0
 
@@ -34,6 +36,8 @@ cleanup()
 	ip netns del $ns1
 }
 
+mptcp_lib_check_mptcp
+
 ip -Version > /dev/null 2>&1
 if [ $? -ne 0 ];then
 	echo "SKIP: Could not run test without ip tool"

-- 
2.39.2


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

* [PATCH mptcp-net v2 03/37] selftests: mptcp: join: skip if MPTCP is not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 01/37] selftests: mptcp: connect: skip if MPTCP is " Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 02/37] selftests: mptcp: pm nl: " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 04/37] selftests: mptcp: diag: " Matthieu Baerts
                   ` (34 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts

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

A new check is then added to make sure MPTCP is supported. If not, the
test stops and is marked as "skipped".

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 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 0044d87556dd..07f6c104fbe7 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -10,6 +10,8 @@
 # because it's invoked by variable name, see how the "tests" array is used
 #shellcheck disable=SC2317
 
+. "$(dirname "${0}")/mptcp_lib.sh"
+
 ret=0
 sin=""
 sinfail=""
@@ -139,6 +141,8 @@ cleanup_partial()
 
 check_tools()
 {
+	mptcp_lib_check_mptcp
+
 	if ! ip -Version &> /dev/null; then
 		echo "SKIP: Could not run test without ip tool"
 		exit $ksft_skip

-- 
2.39.2


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

* [PATCH mptcp-net v2 04/37] selftests: mptcp: diag: skip if MPTCP is not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (2 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 03/37] selftests: mptcp: join: " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 05/37] selftests: mptcp: simult flows: " Matthieu Baerts
                   ` (33 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts

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

A new check is then added to make sure MPTCP is supported. If not, the
test stops and is marked as "skipped".

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368
Fixes: df62f2ec3df6 ("selftests/mptcp: add diag interface tests")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/diag.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
index ef628b16fe9b..4eacdb1ab962 100755
--- a/tools/testing/selftests/net/mptcp/diag.sh
+++ b/tools/testing/selftests/net/mptcp/diag.sh
@@ -1,6 +1,8 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
+. "$(dirname "${0}")/mptcp_lib.sh"
+
 sec=$(date +%s)
 rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
 ns="ns1-$rndh"
@@ -31,6 +33,8 @@ cleanup()
 	ip netns del $ns
 }
 
+mptcp_lib_check_mptcp
+
 ip -Version > /dev/null 2>&1
 if [ $? -ne 0 ];then
 	echo "SKIP: Could not run test without ip tool"

-- 
2.39.2


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

* [PATCH mptcp-net v2 05/37] selftests: mptcp: simult flows: skip if MPTCP is not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (3 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 04/37] selftests: mptcp: diag: " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 06/37] selftests: mptcp: sockopt: " Matthieu Baerts
                   ` (32 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts

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

A new check is then added to make sure MPTCP is supported. If not, the
test stops and is marked as "skipped".

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368
Fixes: 1a418cb8e888 ("mptcp: simult flow self-tests")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/simult_flows.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index 9f22f7e5027d..36a3c9d92e20 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -1,6 +1,8 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
+. "$(dirname "${0}")/mptcp_lib.sh"
+
 sec=$(date +%s)
 rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
 ns1="ns1-$rndh"
@@ -34,6 +36,8 @@ cleanup()
 	done
 }
 
+mptcp_lib_check_mptcp
+
 ip -Version > /dev/null 2>&1
 if [ $? -ne 0 ];then
 	echo "SKIP: Could not run test without ip tool"

-- 
2.39.2


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

* [PATCH mptcp-net v2 06/37] selftests: mptcp: sockopt: skip if MPTCP is not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (4 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 05/37] selftests: mptcp: simult flows: " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 07/37] selftests: mptcp: userspace pm: " Matthieu Baerts
                   ` (31 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts

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

A new check is then added to make sure MPTCP is supported. If not, the
test stops and is marked as "skipped".

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368
Fixes: dc65fe82fb07 ("selftests: mptcp: add packet mark test case")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index 1b70c0a304ce..ff5adbb9c7f2 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -1,6 +1,8 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
+. "$(dirname "${0}")/mptcp_lib.sh"
+
 ret=0
 sin=""
 sout=""
@@ -84,6 +86,8 @@ cleanup()
 	rm -f "$sin" "$sout"
 }
 
+mptcp_lib_check_mptcp
+
 ip -Version > /dev/null 2>&1
 if [ $? -ne 0 ];then
 	echo "SKIP: Could not run test without ip tool"

-- 
2.39.2


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

* [PATCH mptcp-net v2 07/37] selftests: mptcp: userspace pm: skip if MPTCP is not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (5 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 06/37] selftests: mptcp: sockopt: " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 17:34   ` Paolo Abeni
  2023-05-22 16:37 ` [PATCH mptcp-net v2 08/37] selftests: mptcp: lib: skip if missing symbol Matthieu Baerts
                   ` (30 subsequent siblings)
  37 siblings, 1 reply; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: Matthieu Baerts

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

A new check is then added to make sure MPTCP is supported. If not, the
test stops and is marked as "skipped".

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 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
index b1eb7bce599d..8092399d911f 100755
--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
+++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
@@ -1,6 +1,10 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
+. "$(dirname "${0}")/mptcp_lib.sh"
+
+mptcp_lib_check_mptcp
+
 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] 53+ messages in thread

* [PATCH mptcp-net v2 08/37] selftests: mptcp: lib: skip if missing symbol
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (6 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 07/37] selftests: mptcp: userspace pm: " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 09/37] selftests: mptcp: lib: skip if not below kernel version Matthieu Baerts
                   ` (29 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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] 53+ messages in thread

* [PATCH mptcp-net v2 09/37] selftests: mptcp: lib: skip if not below kernel version
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (7 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 08/37] selftests: mptcp: lib: skip if missing symbol Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 17:48   ` Paolo Abeni
  2023-05-22 16:37 ` [PATCH mptcp-net v2 10/37] selftests: mptcp: connect: skip transp tests if not supported Matthieu Baerts
                   ` (28 subsequent siblings)
  37 siblings, 1 reply; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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.

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>
---
 tools/testing/selftests/net/mptcp/mptcp_lib.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index 29b65f4b73b2..dcfe5eb6f7c0 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -76,3 +76,24 @@ 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
+
+	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] 53+ messages in thread

* [PATCH mptcp-net v2 10/37] selftests: mptcp: connect: skip transp tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (8 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 09/37] selftests: mptcp: lib: skip if not below kernel version Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 17:26   ` Paolo Abeni
  2023-05-22 16:37 ` [PATCH mptcp-net v2 11/37] selftests: mptcp: connect: skip disconnect " Matthieu Baerts
                   ` (27 subsequent siblings)
  37 siblings, 1 reply; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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>
---
 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..c6fcae6b2562 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: TFO 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] 53+ messages in thread

* [PATCH mptcp-net v2 11/37] selftests: mptcp: connect: skip disconnect tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (9 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 10/37] selftests: mptcp: connect: skip transp tests if not supported Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 12/37] selftests: mptcp: connect: skip TFO " Matthieu Baerts
                   ` (26 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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 c6fcae6b2562..1b2327d569a5 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] 53+ messages in thread

* [PATCH mptcp-net v2 12/37] selftests: mptcp: connect: skip TFO tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (10 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 11/37] selftests: mptcp: connect: skip disconnect " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 13/37] selftests: mptcp: diag: skip listen " Matthieu Baerts
                   ` (25 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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 1b2327d569a5..9cebe0252b78 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] 53+ messages in thread

* [PATCH mptcp-net v2 13/37] selftests: mptcp: diag: skip listen tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (11 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 12/37] selftests: mptcp: connect: skip TFO " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 14/37] selftests: mptcp: diag: skip inuse " Matthieu Baerts
                   ` (24 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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] 53+ messages in thread

* [PATCH mptcp-net v2 14/37] selftests: mptcp: diag: skip inuse tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (12 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 13/37] selftests: mptcp: diag: skip listen " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 15/37] selftests: mptcp: pm nl: remove hardcoded default limits Matthieu Baerts
                   ` (23 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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] 53+ messages in thread

* [PATCH mptcp-net v2 15/37] selftests: mptcp: pm nl: remove hardcoded default limits
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (13 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 14/37] selftests: mptcp: diag: skip inuse " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 16/37] selftests: mptcp: pm nl: skip fullmesh flag checks if not supported Matthieu Baerts
                   ` (22 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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] 53+ messages in thread

* [PATCH mptcp-net v2 16/37] selftests: mptcp: pm nl: skip fullmesh flag checks if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (14 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 15/37] selftests: mptcp: pm nl: remove hardcoded default limits Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 17/37] selftests: mptcp: sockopt: relax expected returned size Matthieu Baerts
                   ` (21 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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] 53+ messages in thread

* [PATCH mptcp-net v2 17/37] selftests: mptcp: sockopt: relax expected returned size
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (15 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 16/37] selftests: mptcp: pm nl: skip fullmesh flag checks if not supported Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 18/37] selftests: mptcp: sockopt: skip getsockopt checks if not supported Matthieu Baerts
                   ` (20 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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>
---
 tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index ae61f39556ca..7bb42fd4b0a0 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -349,13 +349,13 @@ 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_user > 0);
+		assert(ti.d.size_kernel > 0);
 		assert(ti.d.num_subflows == 1);
 
 		assert(olen > (socklen_t)sizeof(struct mptcp_subflow_data));
 		olen -= sizeof(struct mptcp_subflow_data);
-		assert(olen == sizeof(struct tcp_info));
+		assert(olen == ti.d.size_user);
 
 		if (ti.ti[0].tcpi_bytes_sent == w &&
 		    ti.ti[0].tcpi_bytes_received == r)
@@ -401,13 +401,13 @@ static void do_getsockopt_subflow_addrs(int fd)
 		die_perror("getsockopt MPTCP_SUBFLOW_ADDRS");
 
 	assert(olen <= sizeof(addrs));
-	assert(addrs.d.size_user == addrs.d.size_kernel);
-	assert(addrs.d.size_user == sizeof(struct mptcp_subflow_addrs));
+	assert(addrs.d.size_user > 0);
+	assert(addrs.d.size_kernel > 0);
 	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] 53+ messages in thread

* [PATCH mptcp-net v2 18/37] selftests: mptcp: sockopt: skip getsockopt checks if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (16 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 17/37] selftests: mptcp: sockopt: relax expected returned size Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 19/37] selftests: mptcp: sockopt: skip TCP_INQ " Matthieu Baerts
                   ` (19 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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] 53+ messages in thread

* [PATCH mptcp-net v2 19/37] selftests: mptcp: sockopt: skip TCP_INQ checks if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (17 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 18/37] selftests: mptcp: sockopt: skip getsockopt checks if not supported Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 20/37] selftests: mptcp: userspace pm: skip if 'ip' tool is unavailable Matthieu Baerts
                   ` (18 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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] 53+ messages in thread

* [PATCH mptcp-net v2 20/37] selftests: mptcp: userspace pm: skip if 'ip' tool is unavailable
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (18 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 19/37] selftests: mptcp: sockopt: skip TCP_INQ " Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 21/37] selftests: mptcp: userspace pm: skip if not supported Matthieu Baerts
                   ` (17 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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] 53+ messages in thread

* [PATCH mptcp-net v2 21/37] selftests: mptcp: userspace pm: skip if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (19 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 20/37] selftests: mptcp: userspace pm: skip if 'ip' tool is unavailable Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 22/37] selftests: mptcp: userspace pm: skip PM listener events tests if unavailable Matthieu Baerts
                   ` (16 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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] 53+ messages in thread

* [PATCH mptcp-net v2 22/37] selftests: mptcp: userspace pm: skip PM listener events tests if unavailable
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (20 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 21/37] selftests: mptcp: userspace pm: skip if not supported Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 23/37] selftests: mptcp: join: use 'iptables-legacy' if available Matthieu Baerts
                   ` (15 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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] 53+ messages in thread

* [PATCH mptcp-net v2 23/37] selftests: mptcp: join: use 'iptables-legacy' if available
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (21 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 22/37] selftests: mptcp: userspace pm: skip PM listener events tests if unavailable Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 24/37] selftests: mptcp: join: helpers to skip tests Matthieu Baerts
                   ` (14 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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 07f6c104fbe7..6eabde9d1164 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] 53+ messages in thread

* [PATCH mptcp-net v2 24/37] selftests: mptcp: join: helpers to skip tests
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (22 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 23/37] selftests: mptcp: join: use 'iptables-legacy' if available Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:37 ` [PATCH mptcp-net v2 25/37] selftests: mptcp: join: skip check if MIB counter not supported Matthieu Baerts
                   ` (13 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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 6eabde9d1164..1a8f7c6fa988 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] 53+ messages in thread

* [PATCH mptcp-net v2 25/37] selftests: mptcp: join: skip check if MIB counter not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (23 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 24/37] selftests: mptcp: join: helpers to skip tests Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 17:39   ` Paolo Abeni
  2023-05-22 16:37 ` [PATCH mptcp-net v2 26/37] selftests: mptcp: join: skip test if iptables/tc cmds fail Matthieu Baerts
                   ` (12 subsequent siblings)
  37 siblings, 1 reply; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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.

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 | 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 1a8f7c6fa988..73c513f1e808 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
@@ -1185,12 +1199,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
@@ -1198,12 +1213,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
@@ -1242,12 +1258,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
@@ -1256,12 +1273,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
@@ -1289,10 +1307,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
@@ -1300,10 +1319,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
@@ -1330,9 +1350,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
@@ -1340,9 +1361,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
@@ -1359,9 +1381,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
@@ -1369,9 +1392,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
@@ -1399,9 +1423,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
@@ -1410,9 +1435,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
@@ -1427,9 +1453,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
@@ -1459,12 +1486,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], " \
@@ -1499,12 +1526,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
@@ -1512,9 +1539,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
@@ -1523,9 +1551,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
@@ -1533,10 +1562,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
@@ -1545,10 +1574,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
@@ -1557,10 +1586,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
@@ -1569,10 +1598,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
@@ -1581,10 +1610,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
@@ -1606,12 +1635,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
@@ -1619,9 +1648,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
@@ -1695,9 +1725,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
@@ -1705,12 +1736,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
@@ -1719,14 +1751,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
@@ -1741,9 +1771,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
@@ -1780,9 +1811,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
@@ -1790,9 +1822,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
@@ -1903,7 +1936,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] 53+ messages in thread

* [PATCH mptcp-net v2 26/37] selftests: mptcp: join: skip test if iptables/tc cmds fail
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (24 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 25/37] selftests: mptcp: join: skip check if MIB counter not supported Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 17:42   ` Paolo Abeni
  2023-05-22 16:37 ` [PATCH mptcp-net v2 27/37] selftests: mptcp: join: support local endpoint being tracked or not Matthieu Baerts
                   ` (11 subsequent siblings)
  37 siblings, 1 reply; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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 -- 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.

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 | 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 73c513f1e808..2ae6d99f3eb9 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"
@@ -2029,23 +2055,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
@@ -2053,11 +2079,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] 53+ messages in thread

* [PATCH mptcp-net v2 27/37] selftests: mptcp: join: support local endpoint being tracked or not
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (25 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 26/37] selftests: mptcp: join: skip test if iptables/tc cmds fail Matthieu Baerts
@ 2023-05-22 16:37 ` Matthieu Baerts
  2023-05-22 16:38 ` [PATCH mptcp-net v2 28/37] selftests: mptcp: join: skip Fastclose tests if not supported Matthieu Baerts
                   ` (10 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:37 UTC (permalink / raw)
  To: mptcp; +Cc: 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 2ae6d99f3eb9..1f24495308f9 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2184,11 +2184,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] 53+ messages in thread

* [PATCH mptcp-net v2 28/37] selftests: mptcp: join: skip Fastclose tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (26 preceding siblings ...)
  2023-05-22 16:37 ` [PATCH mptcp-net v2 27/37] selftests: mptcp: join: support local endpoint being tracked or not Matthieu Baerts
@ 2023-05-22 16:38 ` Matthieu Baerts
  2023-05-22 17:45   ` Paolo Abeni
  2023-05-22 16:38 ` [PATCH mptcp-net v2 29/37] selftests: mptcp: join: support RM_ADDR for used endpoints or not Matthieu Baerts
                   ` (9 subsequent siblings)
  37 siblings, 1 reply; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:38 UTC (permalink / raw)
  To: mptcp; +Cc: 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 1f24495308f9..ccf52aba8a1c 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()
 {
@@ -3179,14 +3192,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] 53+ messages in thread

* [PATCH mptcp-net v2 29/37] selftests: mptcp: join: support RM_ADDR for used endpoints or not
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (27 preceding siblings ...)
  2023-05-22 16:38 ` [PATCH mptcp-net v2 28/37] selftests: mptcp: join: skip Fastclose tests if not supported Matthieu Baerts
@ 2023-05-22 16:38 ` Matthieu Baerts
  2023-05-22 16:38 ` [PATCH mptcp-net v2 30/37] selftests: mptcp: join: skip implicit tests if not supported Matthieu Baerts
                   ` (8 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:38 UTC (permalink / raw)
  To: mptcp; +Cc: 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 ccf52aba8a1c..fd0e3c6fa147 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2451,8 +2451,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] 53+ messages in thread

* [PATCH mptcp-net v2 30/37] selftests: mptcp: join: skip implicit tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (28 preceding siblings ...)
  2023-05-22 16:38 ` [PATCH mptcp-net v2 29/37] selftests: mptcp: join: support RM_ADDR for used endpoints or not Matthieu Baerts
@ 2023-05-22 16:38 ` Matthieu Baerts
  2023-05-22 16:38 ` [PATCH mptcp-net v2 31/37] selftests: mptcp: join: skip backup if set flag on ID " Matthieu Baerts
                   ` (7 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:38 UTC (permalink / raw)
  To: mptcp; +Cc: 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.

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>
---
 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 fd0e3c6fa147..c19a1d0ce738 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -3330,8 +3330,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
@@ -3351,7 +3353,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] 53+ messages in thread

* [PATCH mptcp-net v2 31/37] selftests: mptcp: join: skip backup if set flag on ID not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (29 preceding siblings ...)
  2023-05-22 16:38 ` [PATCH mptcp-net v2 30/37] selftests: mptcp: join: skip implicit tests if not supported Matthieu Baerts
@ 2023-05-22 16:38 ` Matthieu Baerts
  2023-05-22 16:38 ` [PATCH mptcp-net v2 32/37] selftests: mptcp: join: skip fullmesh flag tests if " Matthieu Baerts
                   ` (6 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:38 UTC (permalink / raw)
  To: mptcp; +Cc: 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 c19a1d0ce738..3453ef733a4f 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2737,7 +2737,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
@@ -2747,7 +2748,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
@@ -2758,7 +2760,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] 53+ messages in thread

* [PATCH mptcp-net v2 32/37] selftests: mptcp: join: skip fullmesh flag tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (30 preceding siblings ...)
  2023-05-22 16:38 ` [PATCH mptcp-net v2 31/37] selftests: mptcp: join: skip backup if set flag on ID " Matthieu Baerts
@ 2023-05-22 16:38 ` Matthieu Baerts
  2023-05-22 16:38 ` [PATCH mptcp-net v2 33/37] selftests: mptcp: join: skip userspace PM " Matthieu Baerts
                   ` (5 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:38 UTC (permalink / raw)
  To: mptcp; +Cc: 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 3453ef733a4f..795a27933e6c 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -3156,7 +3156,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
@@ -3166,7 +3167,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
@@ -3176,7 +3178,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
@@ -3187,7 +3190,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] 53+ messages in thread

* [PATCH mptcp-net v2 33/37] selftests: mptcp: join: skip userspace PM tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (31 preceding siblings ...)
  2023-05-22 16:38 ` [PATCH mptcp-net v2 32/37] selftests: mptcp: join: skip fullmesh flag tests if " Matthieu Baerts
@ 2023-05-22 16:38 ` Matthieu Baerts
  2023-05-22 16:38 ` [PATCH mptcp-net v2 34/37] selftests: mptcp: join: skip fail " Matthieu Baerts
                   ` (4 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:38 UTC (permalink / raw)
  To: mptcp; +Cc: 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 795a27933e6c..2783a3c59aca 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
@@ -3249,7 +3249,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
@@ -3260,7 +3261,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
@@ -3271,7 +3273,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
@@ -3281,7 +3284,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
@@ -3291,7 +3295,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
@@ -3302,7 +3307,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
@@ -3314,7 +3320,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
@@ -3325,7 +3332,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] 53+ messages in thread

* [PATCH mptcp-net v2 34/37] selftests: mptcp: join: skip fail tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (32 preceding siblings ...)
  2023-05-22 16:38 ` [PATCH mptcp-net v2 33/37] selftests: mptcp: join: skip userspace PM " Matthieu Baerts
@ 2023-05-22 16:38 ` Matthieu Baerts
  2023-05-22 16:38 ` [PATCH mptcp-net v2 35/37] selftests: mptcp: join: skip MPC backups " Matthieu Baerts
                   ` (3 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:38 UTC (permalink / raw)
  To: mptcp; +Cc: 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 2783a3c59aca..37554287eb89 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] 53+ messages in thread

* [PATCH mptcp-net v2 35/37] selftests: mptcp: join: skip MPC backups tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (33 preceding siblings ...)
  2023-05-22 16:38 ` [PATCH mptcp-net v2 34/37] selftests: mptcp: join: skip fail " Matthieu Baerts
@ 2023-05-22 16:38 ` Matthieu Baerts
  2023-05-22 16:38 ` [PATCH mptcp-net v2 36/37] selftests: mptcp: join: skip PM listener " Matthieu Baerts
                   ` (2 subsequent siblings)
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:38 UTC (permalink / raw)
  To: mptcp; +Cc: 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 37554287eb89..dd8633e98185 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2771,14 +2771,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
@@ -2786,14 +2788,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] 53+ messages in thread

* [PATCH mptcp-net v2 36/37] selftests: mptcp: join: skip PM listener tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (34 preceding siblings ...)
  2023-05-22 16:38 ` [PATCH mptcp-net v2 35/37] selftests: mptcp: join: skip MPC backups " Matthieu Baerts
@ 2023-05-22 16:38 ` Matthieu Baerts
  2023-05-22 16:38 ` [PATCH mptcp-net v2 37/37] selftests: mptcp: join: skip mixed " Matthieu Baerts
  2023-05-24 17:04 ` [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:38 UTC (permalink / raw)
  To: mptcp; +Cc: 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 dd8633e98185..48d0b7993194 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2832,6 +2832,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] 53+ messages in thread

* [PATCH mptcp-net v2 37/37] selftests: mptcp: join: skip mixed tests if not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (35 preceding siblings ...)
  2023-05-22 16:38 ` [PATCH mptcp-net v2 36/37] selftests: mptcp: join: skip PM listener " Matthieu Baerts
@ 2023-05-22 16:38 ` Matthieu Baerts
  2023-05-22 19:27   ` selftests: mptcp: join: skip mixed tests if not supported: Tests Results MPTCP CI
  2023-05-22 20:28   ` MPTCP CI
  2023-05-24 17:04 ` [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
  37 siblings, 2 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-22 16:38 UTC (permalink / raw)
  To: mptcp; +Cc: 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 48d0b7993194..484838703532 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2695,7 +2695,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
@@ -2704,7 +2705,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
@@ -2713,7 +2715,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
@@ -2724,7 +2727,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] 53+ messages in thread

* Re: [PATCH mptcp-net v2 10/37] selftests: mptcp: connect: skip transp tests if not supported
  2023-05-22 16:37 ` [PATCH mptcp-net v2 10/37] selftests: mptcp: connect: skip transp tests if not supported Matthieu Baerts
@ 2023-05-22 17:26   ` Paolo Abeni
  2023-05-23  9:34     ` Matthieu Baerts
  0 siblings, 1 reply; 53+ messages in thread
From: Paolo Abeni @ 2023-05-22 17:26 UTC (permalink / raw)
  To: Matthieu Baerts, mptcp

On Mon, 2023-05-22 at 18:37 +0200, Matthieu Baerts wrote:
> 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>
> ---
>  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..c6fcae6b2562 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: TFO not supported by the kernel: SKIP"

Possibly sed -e s/TFO/TOS/ ?

/P


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

* Re: [PATCH mptcp-net v2 07/37] selftests: mptcp: userspace pm: skip if MPTCP is not supported
  2023-05-22 16:37 ` [PATCH mptcp-net v2 07/37] selftests: mptcp: userspace pm: " Matthieu Baerts
@ 2023-05-22 17:34   ` Paolo Abeni
  2023-05-23  9:01     ` Matthieu Baerts
  0 siblings, 1 reply; 53+ messages in thread
From: Paolo Abeni @ 2023-05-22 17:34 UTC (permalink / raw)
  To: Matthieu Baerts, mptcp

On Mon, 2023-05-22 at 18:37 +0200, Matthieu Baerts wrote:
> Selftests are supposed to run on any kernels, including the old ones not
> supporting MPTCP.
> 
> A new check is then added to make sure MPTCP is supported. If not, the
> test stops and is marked as "skipped".
> 
> 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 | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
> index b1eb7bce599d..8092399d911f 100755
> --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
> +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
> @@ -1,6 +1,10 @@
>  #!/bin/bash
>  # SPDX-License-Identifier: GPL-2.0
>  
> +. "$(dirname "${0}")/mptcp_lib.sh"
> +
> +mptcp_lib_check_mptcp
> +
>  ip -Version > /dev/null 2>&1
>  if [ $? -ne 0 ];then
>  	echo "SKIP: Cannot not run test without ip tool"
> 
Up to this patch the series LGTM and IMHO patch 1-7 could be applied
right now.

I think the later patches need a little more discussion. Specifically I
would prefer not introducing all the stuff related to kernel version
and diag dump (e.g. all that stuff that the patches themself warn
about).

/P


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

* Re: [PATCH mptcp-net v2 25/37] selftests: mptcp: join: skip check if MIB counter not supported
  2023-05-22 16:37 ` [PATCH mptcp-net v2 25/37] selftests: mptcp: join: skip check if MIB counter not supported Matthieu Baerts
@ 2023-05-22 17:39   ` Paolo Abeni
  2023-05-23  9:58     ` Matthieu Baerts
  0 siblings, 1 reply; 53+ messages in thread
From: Paolo Abeni @ 2023-05-22 17:39 UTC (permalink / raw)
  To: Matthieu Baerts, mptcp

On Mon, 2023-05-22 at 18:37 +0200, Matthieu Baerts wrote:
> 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.
> 
> 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 | 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 1a8f7c6fa988..73c513f1e808 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
> @@ -1185,12 +1199,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
> @@ -1198,12 +1213,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
> @@ -1242,12 +1258,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
> @@ -1256,12 +1273,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
> @@ -1289,10 +1307,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
> @@ -1300,10 +1319,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
> @@ -1330,9 +1350,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
> @@ -1340,9 +1361,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
> @@ -1359,9 +1381,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
> @@ -1369,9 +1392,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
> @@ -1399,9 +1423,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
> @@ -1410,9 +1435,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
> @@ -1427,9 +1453,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
> @@ -1459,12 +1486,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], " \
> @@ -1499,12 +1526,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
> @@ -1512,9 +1539,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
> @@ -1523,9 +1551,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
> @@ -1533,10 +1562,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
> @@ -1545,10 +1574,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
> @@ -1557,10 +1586,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
> @@ -1569,10 +1598,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
> @@ -1581,10 +1610,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
> @@ -1606,12 +1635,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
> @@ -1619,9 +1648,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
> @@ -1695,9 +1725,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
> @@ -1705,12 +1736,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
> @@ -1719,14 +1751,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
> @@ -1741,9 +1771,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
> @@ -1780,9 +1811,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
> @@ -1790,9 +1822,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
> @@ -1903,7 +1936,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))
> 

This looks quite invasive. I would instead skip the whole mp_join tests
if any of the basic counters are not available - to there will be a
single hook/check.

/P


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

* Re: [PATCH mptcp-net v2 26/37] selftests: mptcp: join: skip test if iptables/tc cmds fail
  2023-05-22 16:37 ` [PATCH mptcp-net v2 26/37] selftests: mptcp: join: skip test if iptables/tc cmds fail Matthieu Baerts
@ 2023-05-22 17:42   ` Paolo Abeni
  2023-05-23 10:10     ` Matthieu Baerts
  0 siblings, 1 reply; 53+ messages in thread
From: Paolo Abeni @ 2023-05-22 17:42 UTC (permalink / raw)
  To: Matthieu Baerts, mptcp

On Mon, 2023-05-22 at 18:37 +0200, Matthieu Baerts wrote:
> 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 -- 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.
> 
> 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 | 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 73c513f1e808..2ae6d99f3eb9 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
> +}

All the above tc/nf features look quite old. I thought even older them
mptcp itself. Do we really need to check for them?!?

/P


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

* Re: [PATCH mptcp-net v2 28/37] selftests: mptcp: join: skip Fastclose tests if not supported
  2023-05-22 16:38 ` [PATCH mptcp-net v2 28/37] selftests: mptcp: join: skip Fastclose tests if not supported Matthieu Baerts
@ 2023-05-22 17:45   ` Paolo Abeni
  2023-05-23 10:14     ` Matthieu Baerts
  0 siblings, 1 reply; 53+ messages in thread
From: Paolo Abeni @ 2023-05-22 17:45 UTC (permalink / raw)
  To: Matthieu Baerts, mptcp

On Mon, 2023-05-22 at 18:38 +0200, Matthieu Baerts wrote:
> 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 1f24495308f9..ccf52aba8a1c 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()
>  {
> @@ -3179,14 +3192,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
> 

Here and in a few later patches, I would do the 'feature check' only
once at the beginning of the functional block ('fastclose_test' in this
case), in the most conservative way possible. The goal would be
minimize the conflicts caused by present/absence of such patch.

/P


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

* Re: [PATCH mptcp-net v2 09/37] selftests: mptcp: lib: skip if not below kernel version
  2023-05-22 16:37 ` [PATCH mptcp-net v2 09/37] selftests: mptcp: lib: skip if not below kernel version Matthieu Baerts
@ 2023-05-22 17:48   ` Paolo Abeni
  2023-05-23  9:12     ` Matthieu Baerts
  0 siblings, 1 reply; 53+ messages in thread
From: Paolo Abeni @ 2023-05-22 17:48 UTC (permalink / raw)
  To: Matthieu Baerts, mptcp

On Mon, 2023-05-22 at 18:37 +0200, Matthieu Baerts wrote:
> 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.
> 
> 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>
> ---
>  tools/testing/selftests/net/mptcp/mptcp_lib.sh | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> index 29b65f4b73b2..dcfe5eb6f7c0 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> @@ -76,3 +76,24 @@ 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

IMHO the above wording is a symptom we should not introduce this infra,
nor the patches using it.

Yep, self test will not be perfect on all older kernel :)

/P


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

* Re: selftests: mptcp: join: skip mixed tests if not supported: Tests Results
  2023-05-22 16:38 ` [PATCH mptcp-net v2 37/37] selftests: mptcp: join: skip mixed " Matthieu Baerts
@ 2023-05-22 19:27   ` MPTCP CI
  2023-05-22 20:28   ` MPTCP CI
  1 sibling, 0 replies; 53+ messages in thread
From: MPTCP CI @ 2023-05-22 19:27 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):
  - Unstable: 1 failed test(s): packetdrill_fastopen 🔴:
  - Task: https://cirrus-ci.com/task/4875564574572544
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/4875564574572544/summary/summary.txt

- {"code":404,"message":
  - "Can't find artifacts containing file conclusion.txt"}:
  - Task: https://cirrus-ci.com/task/5438514527993856
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5438514527993856/summary/summary.txt

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

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

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


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] 53+ messages in thread

* Re: selftests: mptcp: join: skip mixed tests if not supported: Tests Results
  2023-05-22 16:38 ` [PATCH mptcp-net v2 37/37] selftests: mptcp: join: skip mixed " Matthieu Baerts
  2023-05-22 19:27   ` selftests: mptcp: join: skip mixed tests if not supported: Tests Results MPTCP CI
@ 2023-05-22 20:28   ` MPTCP CI
  1 sibling, 0 replies; 53+ messages in thread
From: MPTCP CI @ 2023-05-22 20:28 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):
  - Unstable: 1 failed test(s): packetdrill_fastopen 🔴:
  - Task: https://cirrus-ci.com/task/4875564574572544
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/4875564574572544/summary/summary.txt

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

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

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

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


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] 53+ messages in thread

* Re: [PATCH mptcp-net v2 07/37] selftests: mptcp: userspace pm: skip if MPTCP is not supported
  2023-05-22 17:34   ` Paolo Abeni
@ 2023-05-23  9:01     ` Matthieu Baerts
  0 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-23  9:01 UTC (permalink / raw)
  To: Paolo Abeni, mptcp

Hi Paolo,

On 22/05/2023 19:34, Paolo Abeni wrote:
> On Mon, 2023-05-22 at 18:37 +0200, Matthieu Baerts wrote:
>> Selftests are supposed to run on any kernels, including the old ones not
>> supporting MPTCP.
>>
>> A new check is then added to make sure MPTCP is supported. If not, the
>> test stops and is marked as "skipped".
>>
>> 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 | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
>> index b1eb7bce599d..8092399d911f 100755
>> --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
>> +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
>> @@ -1,6 +1,10 @@
>>  #!/bin/bash
>>  # SPDX-License-Identifier: GPL-2.0
>>  
>> +. "$(dirname "${0}")/mptcp_lib.sh"
>> +
>> +mptcp_lib_check_mptcp
>> +
>>  ip -Version > /dev/null 2>&1
>>  if [ $? -ne 0 ];then
>>  	echo "SKIP: Cannot not run test without ip tool"
>>
> Up to this patch the series LGTM and IMHO patch 1-7 could be applied
> right now.

Thank you for the quick review!

I just applied these 7 first patches with your Acked-by (I hope that's
OK) in our tree (fixes for -net):

New patches for t/upstream-net & t/upstream:
- b809e4daae06: selftests: mptcp: connect: skip if MPTCP is not supported
- bb32747eda98: selftests: mptcp: pm nl: skip if MPTCP is not supported
- 62f43cd362f2: selftests: mptcp: join: skip if MPTCP is not supported
- 225c8e1cba4f: selftests: mptcp: diag: skip if MPTCP is not supported
- 6ca8a8d4621e: selftests: mptcp: simult flows: skip if MPTCP is not
supported
- 7a8db23cbea0: selftests: mptcp: sockopt: skip if MPTCP is not supported
- a6a7d97d9d46: selftests: mptcp: userspace pm: skip if MPTCP is not
supported
- Results: 8a13ec4e7433..dfcc25846d11 (export-net)
- Results: e9959fe44675..1a26d4e0d882 (export)

Tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export-net/20230523T085808
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20230523T085808

> I think the later patches need a little more discussion. Specifically I
> would prefer not introducing all the stuff related to kernel version
> and diag dump (e.g. all that stuff that the patches themself warn
> about).

I understand that it requires further discussions. I will reply on the
different patches but we can also discuss about that at the weekly
meeting today.

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

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

* Re: [PATCH mptcp-net v2 09/37] selftests: mptcp: lib: skip if not below kernel version
  2023-05-22 17:48   ` Paolo Abeni
@ 2023-05-23  9:12     ` Matthieu Baerts
  0 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-23  9:12 UTC (permalink / raw)
  To: Paolo Abeni, mptcp

Hi Paolo,

On 22/05/2023 19:48, Paolo Abeni wrote:
> On Mon, 2023-05-22 at 18:37 +0200, Matthieu Baerts wrote:
>> 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.
>>
>> 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>
>> ---
>>  tools/testing/selftests/net/mptcp/mptcp_lib.sh | 21 +++++++++++++++++++++
>>  1 file changed, 21 insertions(+)
>>
>> diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
>> index 29b65f4b73b2..dcfe5eb6f7c0 100644
>> --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
>> +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
>> @@ -76,3 +76,24 @@ 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
> 
> IMHO the above wording is a symptom we should not introduce this infra,
> nor the patches using it.
> 
> Yep, self test will not be perfect on all older kernel :)

I understand, that's something we should avoid. But the thing is that
even if selftests cannot be perfect on older kernels, when one sub-test
fails, the whole selftest is marked as failed, making all the other
sub-test useless because we only track the result of the whole selftest.

In other words, if MPTCP join subtest 42/100 is always failing on kernel
5.15 because a feature is not supported, the result of the 99 other
subtests will be ignored most of the time because we will only track the
result of the selftest which will be "failed" all the time.

To support kernels backporting new features, we can also add a new env
var to skip this check (always returning that the version is recent
enough). WDYT?

Anyway I guess on these kernels, only the selftests from the same kernel
version is used (not the one from the last dev branch).

But if we see other (easy) way to check if a feature is present, always
better to use alternatives.

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

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

* Re: [PATCH mptcp-net v2 10/37] selftests: mptcp: connect: skip transp tests if not supported
  2023-05-22 17:26   ` Paolo Abeni
@ 2023-05-23  9:34     ` Matthieu Baerts
  0 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-23  9:34 UTC (permalink / raw)
  To: Paolo Abeni, mptcp

On 22/05/2023 19:26, Paolo Abeni wrote:
> On Mon, 2023-05-22 at 18:37 +0200, Matthieu Baerts wrote:
>> 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>
>> ---
>>  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..c6fcae6b2562 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: TFO not supported by the kernel: SKIP"
> 
> Possibly sed -e s/TFO/TOS/ ?

Good catch!

In the future v3, I did s/TFO/${msg}/ to print a different message for
v4 and v6.

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

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

* Re: [PATCH mptcp-net v2 25/37] selftests: mptcp: join: skip check if MIB counter not supported
  2023-05-22 17:39   ` Paolo Abeni
@ 2023-05-23  9:58     ` Matthieu Baerts
  0 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-23  9:58 UTC (permalink / raw)
  To: Paolo Abeni, mptcp

Hi Paolo,

On 22/05/2023 19:39, Paolo Abeni wrote:
> On Mon, 2023-05-22 at 18:37 +0200, Matthieu Baerts wrote:
>> 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.
>>
>> 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 | 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 1a8f7c6fa988..73c513f1e808 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}"
>> +}

(...)

> This looks quite invasive. I would instead skip the whole mp_join tests
> if any of the basic counters are not available - to there will be a
> single hook/check.

I agree that it is quite invasive but the idea is to backport it to
stable. Once this is done, it should not cause troubles to do other
backports.

Also, this new helper does a few things:

- It makes sure we get one counter to avoid issues we had in the past
where some counters were sharing the same prefix, e.g. MPTcpExtRmAddr
and MPTcpExtRmAddrDrop

- When a MIB counter is missing, the checks using it are skipped

- Our CI will catch typos

- (getting MIB counters is now uniformed)

Initially I used the helpers for counters that are more recent and for
the ones sharing the same prefixes but that was creating quite a lot of
commits and I was thinking it might be better to uniform them.

It should not be too hard to backports: we don't really change this part
so if there is are conflicts, it is very likely because a counter is not
used somewhere so we don't need that chunk.

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

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

* Re: [PATCH mptcp-net v2 26/37] selftests: mptcp: join: skip test if iptables/tc cmds fail
  2023-05-22 17:42   ` Paolo Abeni
@ 2023-05-23 10:10     ` Matthieu Baerts
  0 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-23 10:10 UTC (permalink / raw)
  To: Paolo Abeni, mptcp

Hi Paolo,

On 22/05/2023 19:42, Paolo Abeni wrote:
> On Mon, 2023-05-22 at 18:37 +0200, Matthieu Baerts wrote:
>> 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 -- we should intercept the error and skip the
>> tests requiring these features.

(...)

> All the above tc/nf features look quite old. I thought even older them
> mptcp itself. Do we really need to check for them?!?

It should indeed not be required but when doing the validation on older
kernels, I had issues with 'iptables-nft'. We could also have similar
issues if a kconfig is missing or if there is something wrong with the
Netfilter stack.

The consequence is that either the test was finishing in the middle
(because of the "exit 1" next to some commands) or the errors were
ignored and it was not clear why.

What is mainly interesting here is that we check we can add the specific
rules before starting a test and we stop only the subtest in case of
issue. If it doesn't hurt, maybe safer to keep this?

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

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

* Re: [PATCH mptcp-net v2 28/37] selftests: mptcp: join: skip Fastclose tests if not supported
  2023-05-22 17:45   ` Paolo Abeni
@ 2023-05-23 10:14     ` Matthieu Baerts
  0 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-23 10:14 UTC (permalink / raw)
  To: Paolo Abeni, mptcp

Hi Paolo,

On 22/05/2023 19:45, Paolo Abeni wrote:
> On Mon, 2023-05-22 at 18:38 +0200, Matthieu Baerts wrote:
>> 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 1f24495308f9..ccf52aba8a1c 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()
>>  {
>> @@ -3179,14 +3192,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
>>
> 
> Here and in a few later patches, I would do the 'feature check' only
> once at the beginning of the functional block ('fastclose_test' in this
> case), in the most conservative way possible. The goal would be
> minimize the conflicts caused by present/absence of such patch.

I initially did that but then it breaks the feature to start a specific
test. Also, the ID of the tests would be different on the different
kernels which might make the tracking of the different issues more
difficult.

On older kernels, we already have conflicts because of all the "if reset
(...)" I introduced one or two years ago :)

But likely, we don't need to backport such checks to know if a test can
be started or not too far: as long as we can backport such checks to the
last stable kernels, that's enough for the different CIs using the last
stable version of the kselftests on older kernels.

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

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

* Re: [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported
  2023-05-22 16:37 [PATCH mptcp-net v2 00/37] selftests: mptcp: skip tests when features are not supported Matthieu Baerts
                   ` (36 preceding siblings ...)
  2023-05-22 16:38 ` [PATCH mptcp-net v2 37/37] selftests: mptcp: join: skip mixed " Matthieu Baerts
@ 2023-05-24 17:04 ` Matthieu Baerts
  37 siblings, 0 replies; 53+ messages in thread
From: Matthieu Baerts @ 2023-05-24 17:04 UTC (permalink / raw)
  To: Paolo Abeni; +Cc: MPTCP Upstream

Hi Paolo,

(and anybody interested by this ;-) )

On 22/05/2023 18:37, Matthieu Baerts wrote:
> Selftests are supposed to run on any kernels, including the old ones not
> supporting all MPTCP features.

We discussed about this series at the meeting yesterday but I don't
think the next steps are clear, at least not to me :-)

Here is a short recap of the current situation:

- The first patches skipping MPTCP if it is not supported have been applied.

- check kernel version: what about adding an 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)

- 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 :) )

WDYT?

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

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

end of thread, other threads:[~2023-05-24 17:04 UTC | newest]

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