[PATCH mptcp-next] selftests: mptcp: iperf mptcp tests

Geliang Tang posted 1 patch 1 month, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/8f95589ded2c77edbc5086a808703c63b4641e60.1710206580.git.tanggeliang@kylinos.cn
.../testing/selftests/net/mptcp/mptcp_join.sh | 54 ++++++++++++++++++-
.../testing/selftests/net/mptcp/mptcp_lib.sh  |  6 +++
2 files changed, 59 insertions(+), 1 deletion(-)
[PATCH mptcp-next] selftests: mptcp: iperf mptcp tests
Posted by Geliang Tang 1 month, 2 weeks ago
From: Geliang Tang <tanggeliang@kylinos.cn>

MPTCPv1 protocol support has been added in iperf3 recently. This patch
add some tests for iperf3 to demonstrate the advantages of MPTCP over
TCP in latency or packet loss situations.

Note:

Does 'delay 1' in below command mean 'delay 1ms'? I'm not sure.
> tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 1

Should this test be put in a standalone test script or just like in this
patch, as a subtest of mptcp_join.sh?

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 54 ++++++++++++++++++-
 .../testing/selftests/net/mptcp/mptcp_lib.sh  |  6 +++
 2 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 1052b85d8170..f2279bfa27c3 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -141,7 +141,7 @@ init() {
 
 	mptcp_lib_check_mptcp
 	mptcp_lib_check_kallsyms
-	mptcp_lib_check_tools ip ss "${iptables}" "${ip6tables}"
+	mptcp_lib_check_tools ip ss "${iptables}" "${ip6tables}" iperf
 
 	sin=$(mktemp)
 	sout=$(mktemp)
@@ -3570,6 +3570,57 @@ endpoint_tests()
 	fi
 }
 
+iperf_tests()
+{
+	if reset "iperf tcp test, delay 1"; then
+		tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 1
+		ip netns exec $ns1 iperf3 -s &
+		local tests_pid=$!
+		sleep 1
+		ip netns exec $ns2 iperf3 -c 10.0.1.1
+		mptcp_lib_kill_wait $tests_pid
+		chk_join_nr 0 0 0
+	fi
+
+	if reset "iperf mptcp test, delay 1"; then
+		tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 1
+		pm_nl_set_limits $ns1 8 8
+		pm_nl_set_limits $ns2 8 8
+		pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow
+		pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow
+		ip netns exec $ns1 iperf3 -m -s &
+		local tests_pid=$!
+		sleep 1
+		ip netns exec $ns2 iperf3 -m -c 10.0.1.1
+		mptcp_lib_kill_wait $tests_pid
+		chk_join_nr 2 2 2
+	fi
+
+	if reset "iperf tcp test, loss 1%"; then
+		tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit loss 1%
+		ip netns exec $ns1 iperf3 -s &
+		local tests_pid=$!
+		sleep 1
+		ip netns exec $ns2 iperf3 -c 10.0.1.1
+		mptcp_lib_kill_wait $tests_pid
+		chk_join_nr 0 0 0
+	fi
+
+	if reset "iperf mptcp test, loss %1"; then
+		tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit loss 1%
+		pm_nl_set_limits $ns1 8 8
+		pm_nl_set_limits $ns2 8 8
+		pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow
+		pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow
+		ip netns exec $ns1 iperf3 -m -s &
+		local tests_pid=$!
+		sleep 1
+		ip netns exec $ns2 iperf3 -m -c 10.0.1.1
+		mptcp_lib_kill_wait $tests_pid
+		chk_join_nr 2 2 2
+	fi
+}
+
 # [$1: error message]
 usage()
 {
@@ -3618,6 +3669,7 @@ all_tests_sorted=(
 	F@fail_tests
 	u@userspace_tests
 	I@endpoint_tests
+	t@iperf_tests
 )
 
 all_tests_args=""
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index d395692fac0d..8def187c1ef7 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -402,6 +402,12 @@ mptcp_lib_check_tools() {
 				exit ${KSFT_SKIP}
 			fi
 			;;
+		"iperf"*)
+			if ! iperf3 -h | grep -q multipath; then
+				mptcp_lib_pr_skip "iperf tool does not support MPTCP"
+				exit ${KSFT_SKIP}
+			fi
+			;;
 		*)
 			mptcp_lib_pr_fail "Internal error: unsupported tool: ${tool}"
 			exit ${KSFT_FAIL}
-- 
2.40.1
Re: [PATCH mptcp-next] selftests: mptcp: iperf mptcp tests
Posted by Matthieu Baerts 1 month, 2 weeks ago
Hi Geliang,

On 12/03/2024 02:23, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> MPTCPv1 protocol support has been added in iperf3 recently. This patch
> add some tests for iperf3 to demonstrate the advantages of MPTCP over
> TCP in latency or packet loss situations.
> 
> Note:

Thank you for the note, it is useful.

> Does 'delay 1' in below command mean 'delay 1ms'? I'm not sure.
>> tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 1

Accoring to 'man tc-netem' (8), it is in milliseconds:

   delay
       adds the chosen delay to the packets outgoing to chosen network
       interface.  The  optional  parameters allows one to introduce a
       delay variation and a correlation.  Delay and jitter values are
       expressed in ms while correlation is percentage.

But I think you can specify '1ms' to make it clear, no?

> Should this test be put in a standalone test script or just like in this
> patch, as a subtest of mptcp_join.sh?

I don't know. I don't think we should add IPerf tests in the selftests:

- I don't think it is validating any more kernel code path than what we
already have: we already have a lot of tests in MPTCP Join selftest,
let's only add new ones validating untested kernel code, no?

- I don't think we should validate many userspace tools from the kernel
side: we probably don't have the resources to do that. We should focus
on minimal tools validating different code paths.

- Probably best not to depend on external tools: it makes it harder to
have these tests validated by other CIs.

In other words, I think tests for userspace apps should not be on the
kernelspace side, but stay on the userspace side. WDYT?

(...)

> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 1052b85d8170..f2279bfa27c3 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -141,7 +141,7 @@ init() {
>  
>  	mptcp_lib_check_mptcp
>  	mptcp_lib_check_kallsyms
> -	mptcp_lib_check_tools ip ss "${iptables}" "${ip6tables}"
> +	mptcp_lib_check_tools ip ss "${iptables}" "${ip6tables}" iperf

This means 'iper3' with MPTCP support is now a hard dependence for this
selftests: without it, nothing is launched. We cannot do: most CIs will
not have this tool, many tests will then no longer be validated.

(...)

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.