[PATCH mptcp-next v3] selftests: mptcp: add mptcp_info tests

Geliang Tang posted 1 patch 1 year, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/9b5a84ef14899800a8a0036cceae0406e016596f.1678327360.git.geliang.tang@suse.com
Maintainers: Matthieu Baerts <matthieu.baerts@tessares.net>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Shuah Khan <shuah@kernel.org>
There is a newer version of this series
.../testing/selftests/net/mptcp/mptcp_join.sh | 43 +++++++++++++++++++
1 file changed, 43 insertions(+)
[PATCH mptcp-next v3] selftests: mptcp: add mptcp_info tests
Posted by Geliang Tang 1 year, 1 month ago
This patch adds the mptcp_info fields tests in endpoint_tests(). Add a
new function chk_mptcp_info() to check the given number of the given
mptcp_info field.

Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/330
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
v2:
 - use '-D' option instead of '-i'.
v3:
 - add tests in endpoint_tests() instead.
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 42e3bd1a05f5..625d24d94576 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -1719,6 +1719,46 @@ chk_subflow_nr()
 	fi
 }
 
+chk_mptcp_info()
+{
+	local nr_info=$1
+	local info
+	local cnt1
+	local cnt2
+	local dump_stats
+
+	if [[ $nr_info = "subflows_"* ]]; then
+		info="subflows"
+		nr_info=${nr_info:9}
+	else
+		echo "[fail] $nr_info"
+		fail_test
+		dump_stats=1
+	fi
+
+	printf "%-${nr_blank}s %-30s" " " "mptcp_info $info=$nr_info"
+
+	cnt1=$(ss -N $ns1 -inmHM | grep "$info:" |
+		sed -n 's/.*\('"$info"':\)\([[:digit:]]*\).*$/\2/p;q')
+	[ -z $cnt1 ] && cnt1=0
+	cnt2=$(ss -N $ns2 -inmHM | grep "$info:" |
+		sed -n 's/.*\('"$info"':\)\([[:digit:]]*\).*$/\2/p;q')
+	[ -z $cnt2 ] && cnt2=0
+	if [ $cnt1 != $nr_info -o $cnt2 != $nr_info ]; then
+		echo "[fail] got $cnt1:$cnt2 $info expected $nr_info"
+		fail_test
+		dump_stats=1
+	else
+		echo "[ ok ]"
+	fi
+
+	if [ "$dump_stats" = 1 ]; then
+		ss -N $ns1 -inmHM
+		ss -N $ns2 -inmHM
+		dump_stats
+	fi
+}
+
 chk_link_usage()
 {
 	local ns=$1
@@ -3118,13 +3158,16 @@ endpoint_tests()
 		run_tests $ns1 $ns2 10.0.1.1 4 0 0 speed_20 2>/dev/null &
 
 		wait_mpj $ns2
+		chk_mptcp_info subflows_1
 		pm_nl_del_endpoint $ns2 2 10.0.2.2
 		sleep 0.5
 		chk_subflow_nr needtitle "after delete" 1
+		chk_mptcp_info subflows_0
 
 		pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow
 		wait_mpj $ns2
 		chk_subflow_nr "" "after re-add" 2
+		chk_mptcp_info subflows_1
 		kill_tests_wait
 	fi
 }
-- 
2.35.3
Re: [PATCH mptcp-next v3] selftests: mptcp: add mptcp_info tests
Posted by Matthieu Baerts 1 year, 1 month ago
Hi Geliang,

On 09/03/2023 03:04, Geliang Tang wrote:
> This patch adds the mptcp_info fields tests in endpoint_tests(). Add a
> new function chk_mptcp_info() to check the given number of the given
> mptcp_info field.
> 
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/330
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> v2:
>  - use '-D' option instead of '-i'.
> v3:
>  - add tests in endpoint_tests() instead.
> ---
>  .../testing/selftests/net/mptcp/mptcp_join.sh | 43 +++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 42e3bd1a05f5..625d24d94576 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh

(..)

> @@ -3118,13 +3158,16 @@ endpoint_tests()
>  		run_tests $ns1 $ns2 10.0.1.1 4 0 0 speed_20 2>/dev/null &
>  
>  		wait_mpj $ns2
> +		chk_mptcp_info subflows_1

I forgot to look at the output when doing my previous review and it
seems this is printed before the title:

#                          mptcp_info subflows=1         [ ok ]
# 115 delete and re-add    after delete[ ok ]
#                          mptcp_info subflows=0         [ ok ]
#                          after re-add[ ok ]
#                          mptcp_info subflows=1         [ ok ]

Maybe we should have:

  (...)

  wait_mpj $ns2
  chk_subflow_nr needtitle "before delete" 2
  chk_mptcp_info subflows_1

  pm_nl_del_endpoint $ns2 2 10.0.2.2
  sleep 0.5
  chk_subflow_nr "" "after delete" 1
  chk_mptcp_info subflows_0

  (...)

What do you think?

Do you mind looking at that in a v4 (with the other comments) please?

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
Re: [PATCH mptcp-next v3] selftests: mptcp: add mptcp_info tests
Posted by Matthieu Baerts 1 year, 1 month ago
Hi Geliang,

On 09/03/2023 03:04, Geliang Tang wrote:
> This patch adds the mptcp_info fields tests in endpoint_tests(). Add a
> new function chk_mptcp_info() to check the given number of the given
> mptcp_info field.
> 
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/330
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> v2:
>  - use '-D' option instead of '-i'.
> v3:
>  - add tests in endpoint_tests() instead.
> ---
>  .../testing/selftests/net/mptcp/mptcp_join.sh | 43 +++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 42e3bd1a05f5..625d24d94576 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -1719,6 +1719,46 @@ chk_subflow_nr()
>  	fi
>  }
>  
> +chk_mptcp_info()
> +{
> +	local nr_info=$1
> +	local info
> +	local cnt1
> +	local cnt2
> +	local dump_stats
> +
> +	if [[ $nr_info = "subflows_"* ]]; then
> +		info="subflows"
> +		nr_info=${nr_info:9}
> +	else
> +		echo "[fail] $nr_info"
> +		fail_test
> +		dump_stats=1

Do you mind if I replace "dump_stats=1" by a "return 1" when applying
the patch? No need to do the rest that will probably cause bash errors
below.

And while at it, I just change the 'echo' to say:

  [fail] unsupported argument: $nr_info

> +	fi
> +
> +	printf "%-${nr_blank}s %-30s" " " "mptcp_info $info=$nr_info"
> +
> +	cnt1=$(ss -N $ns1 -inmHM | grep "$info:" |
> +		sed -n 's/.*\('"$info"':\)\([[:digit:]]*\).*$/\2/p;q')
> +	[ -z $cnt1 ] && cnt1=0
> +	cnt2=$(ss -N $ns2 -inmHM | grep "$info:" |
> +		sed -n 's/.*\('"$info"':\)\([[:digit:]]*\).*$/\2/p;q')
> +	[ -z $cnt2 ] && cnt2=0
> +	if [ $cnt1 != $nr_info -o $cnt2 != $nr_info ]; then

While at it, I will also add double quotes around variables just in case
the parsing fails and return a few words [1] and use "||" instead of
"-o" [2]

[1] https://www.shellcheck.net/wiki/SC2086
[2] https://www.shellcheck.net/wiki/SC2166

Also, do you plan to add a similar test but with the userspace pm?


Apart from that and if you are OK with the suggested modifications, the
rest looks good to me!

Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
Re: [PATCH mptcp-next v3] selftests: mptcp: add mptcp_info tests
Posted by Geliang Tang 1 year, 1 month ago
On Thu, Mar 09, 2023 at 09:38:34AM +0100, Matthieu Baerts wrote:
> Hi Geliang,
> 
> On 09/03/2023 03:04, Geliang Tang wrote:
> > This patch adds the mptcp_info fields tests in endpoint_tests(). Add a
> > new function chk_mptcp_info() to check the given number of the given
> > mptcp_info field.
> > 
> > Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/330
> > Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> > ---
> > v2:
> >  - use '-D' option instead of '-i'.
> > v3:
> >  - add tests in endpoint_tests() instead.
> > ---
> >  .../testing/selftests/net/mptcp/mptcp_join.sh | 43 +++++++++++++++++++
> >  1 file changed, 43 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> > index 42e3bd1a05f5..625d24d94576 100755
> > --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> > +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> > @@ -1719,6 +1719,46 @@ chk_subflow_nr()
> >  	fi
> >  }
> >  
> > +chk_mptcp_info()
> > +{
> > +	local nr_info=$1
> > +	local info
> > +	local cnt1
> > +	local cnt2
> > +	local dump_stats
> > +
> > +	if [[ $nr_info = "subflows_"* ]]; then
> > +		info="subflows"
> > +		nr_info=${nr_info:9}
> > +	else
> > +		echo "[fail] $nr_info"
> > +		fail_test
> > +		dump_stats=1
> 
> Do you mind if I replace "dump_stats=1" by a "return 1" when applying
> the patch? No need to do the rest that will probably cause bash errors
> below.
> 
> And while at it, I just change the 'echo' to say:
> 
>   [fail] unsupported argument: $nr_info
> 
> > +	fi
> > +
> > +	printf "%-${nr_blank}s %-30s" " " "mptcp_info $info=$nr_info"
> > +
> > +	cnt1=$(ss -N $ns1 -inmHM | grep "$info:" |
> > +		sed -n 's/.*\('"$info"':\)\([[:digit:]]*\).*$/\2/p;q')
> > +	[ -z $cnt1 ] && cnt1=0
> > +	cnt2=$(ss -N $ns2 -inmHM | grep "$info:" |
> > +		sed -n 's/.*\('"$info"':\)\([[:digit:]]*\).*$/\2/p;q')
> > +	[ -z $cnt2 ] && cnt2=0
> > +	if [ $cnt1 != $nr_info -o $cnt2 != $nr_info ]; then
> 
> While at it, I will also add double quotes around variables just in case
> the parsing fails and return a few words [1] and use "||" instead of
> "-o" [2]
> 
> [1] https://www.shellcheck.net/wiki/SC2086
> [2] https://www.shellcheck.net/wiki/SC2166
> 
> Also, do you plan to add a similar test but with the userspace pm?

Yes, this chk_mptcp_info() will be invoked in the userspace pm tests.

> 
> 
> Apart from that and if you are OK with the suggested modifications, the
> rest looks good to me!
> 
> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> 
> Cheers,
> Matt
> -- 
> Tessares | Belgium | Hybrid Access Solutions
> www.tessares.net