diff mbox series

[mptcp-next,v8,11/12] selftests: mptcp: add pm_type mapping tests

Message ID 5af6ae4fa325ea616e4f65beba00a0a20afb60bc.1741088339.git.tanggeliang@kylinos.cn (mailing list archive)
State Superseded
Delegated to: Matthieu Baerts
Headers show
Series BPF path manager, part 5 | expand

Commit Message

Geliang Tang March 4, 2025, 11:40 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

This patch adds a new helper set_path_manager() to set the newly added
net.mptcp.path_manager, and test it inside a userspace pm test.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Matthieu Baerts (NGI0) March 5, 2025, 11:58 a.m. UTC | #1
Hi Geliang,

On 04/03/2025 12:40, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> This patch adds a new helper set_path_manager() to set the newly added
> net.mptcp.path_manager, and test it inside a userspace pm test.
> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 13a3b68181ee..fa1929ca6ad4 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -3572,6 +3572,21 @@ userspace_tests()
>  	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
> +		if continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then

You cannot have a "continue_if" here, that will mark the whole subtest
as skip if the condition is not met, then continue.

Why not having this in userspace_pm.sh as I suggested. It feels wrong to
have it here, in the "join" test, no?

https://lore.kernel.org/c49517d2-38e2-4848-9fb9-1c7748689cec@kernel.org

So in userspace_pm.sh, around "mptcp_lib_ns_init ns1 ns2", having
something like (not tested):

  print_title "Init"
  print_test "Created network namespaces ns1, ns2"
  mptcp_lib_ns_init ns1 ns2

  # check path_manager and pm_type sysctl mapping
  if [ -f /proc/sys/net/mptcp/path_manager ]; then
      ip netns exec "$ns1" sysctl -q net.mptcp.path_manager=userspace
      pm_type="$(ip netns exec "$ns1" sysctl -n net.mptcp.pm_type)"
      if [ "${pm_type}" != "1" ]; then
          test_fail "unexpected pm_type: ${pm_type}"
          mptcp_lib_result_print_all_tap
          exit ${KSFT_FAIL}
      fi

      ip netns exec "$ns1" sysctl -q net.mptcp.pm_type=0
      pm="$(ip netns exec "$ns1" sysctl -n net.mptcp.path_manager)"
      if [ "${pm}" != "kernel" ]; then
          test_fail "unexpected path-manager: ${pm}"
          mptcp_lib_result_print_all_tap
          exit ${KSFT_FAIL}
      fi
  fi

  for i in "$ns1" "$ns2" ;do
      ip netns exec "$i" sysctl -q net.mptcp.pm_type=1
  done

  (...)

WDYT?

Cheers,
Matt
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 13a3b68181ee..fa1929ca6ad4 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -3572,6 +3572,21 @@  userspace_tests()
 	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
+		if continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then
+			local pm1 pm2
+
+			pm1=$(ip netns exec ${ns1} sysctl -n net.mptcp.path_manager)
+			if [ "$pm1" != "userspace" ]; then
+				mptcp_lib_pr_fail "ns1 pm_type mapping fails"
+				return 1
+			fi
+
+			pm2=$(ip netns exec ${ns2} sysctl -n net.mptcp.path_manager)
+			if [ "$pm2" != "kernel" ]; then
+				mptcp_lib_pr_fail "ns2 pm_type mapping fails"
+				return 1
+			fi
+		fi
 		pm_nl_set_limits $ns2 2 2
 		{ speed=5 \
 			run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null