[PATCH mptcp-next 03/10] selftests: mptcp: id support for show_endpoints

Geliang Tang posted 10 patches 1 year, 11 months ago
There is a newer version of this series
[PATCH mptcp-next 03/10] selftests: mptcp: id support for show_endpoints
Posted by Geliang Tang 1 year, 11 months ago
From: Geliang Tang <tanggeliang@kylinos.cn>

All endpoints are showed in pm_nl_show_endpoints(). This patch adds support
for showing a specofic endpoint identified by the given address ID.

Usage:
        All endpoints - pm_nl_show_endpoints $ns
        One endpoint - pm_nl_show_endpoints $ns $id

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

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 8eb5cf54ea42..e33a136aef8e 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -699,11 +699,18 @@ pm_nl_flush_endpoint()
 pm_nl_show_endpoints()
 {
 	local ns=$1
+	local id=$2
 
 	if mptcp_lib_is_ip_mptcp; then
-		ip -n $ns mptcp endpoint show
+		local show="show"
+
+		[ -n "$id" ] && show+=" id $id"
+		ip -n $ns mptcp endpoint $show
 	else
-		ip netns exec $ns ./pm_nl_ctl dump
+		local dump="dump"
+
+		[ -n "$id" ] && dump="get $id"
+		ip netns exec $ns ./pm_nl_ctl $dump
 	fi
 }
 
@@ -3598,6 +3605,10 @@ endpoint_tests()
 		mptcp_lib_is_ip_mptcp && output="add_addr_accepted 2 subflows 2 "
 		check_output "pm_nl_get_limits ${ns1}" "${output}"
 		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
+		print_check "show id 1 addr"
+		output="id 1 flags signal 10.0.2.1"
+		mptcp_lib_is_ip_mptcp && output="10.0.2.1 id 1 signal "
+		check_output "pm_nl_show_endpoints ${ns1} 1" "${output}"
 		speed=slow \
 			run_tests $ns1 $ns2 10.0.1.1 &
 		local tests_pid=$!
-- 
2.40.1
Re: [PATCH mptcp-next 03/10] selftests: mptcp: id support for show_endpoints
Posted by Matthieu Baerts 1 year, 11 months ago
Hi Geliang,

On 11/03/2024 02:48, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> All endpoints are showed in pm_nl_show_endpoints(). This patch adds support
> for showing a specofic endpoint identified by the given address ID.
> 
> Usage:
>         All endpoints - pm_nl_show_endpoints $ns
>         One endpoint - pm_nl_show_endpoints $ns $id
> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 8eb5cf54ea42..e33a136aef8e 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -699,11 +699,18 @@ pm_nl_flush_endpoint()
>  pm_nl_show_endpoints()
>  {
>  	local ns=$1
> +	local id=$2
>  
>  	if mptcp_lib_is_ip_mptcp; then
> -		ip -n $ns mptcp endpoint show
> +		local show="show"
> +
> +		[ -n "$id" ] && show+=" id $id"
> +		ip -n $ns mptcp endpoint $show
>  	else
> -		ip netns exec $ns ./pm_nl_ctl dump
> +		local dump="dump"
> +
> +		[ -n "$id" ] && dump="get $id"
> +		ip netns exec $ns ./pm_nl_ctl $dump
>  	fi
>  }
>  
> @@ -3598,6 +3605,10 @@ endpoint_tests()
>  		mptcp_lib_is_ip_mptcp && output="add_addr_accepted 2 subflows 2 "
>  		check_output "pm_nl_get_limits ${ns1}" "${output}"
>  		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
> +		print_check "show id 1 addr"
> +		output="id 1 flags signal 10.0.2.1"
> +		mptcp_lib_is_ip_mptcp && output="10.0.2.1 id 1 signal "
> +		check_output "pm_nl_show_endpoints ${ns1} 1" "${output}"

Same here, that's already validated in pm_netlink.sh, no need to
duplicate the test validating the same kernel code path. WDYT?

>  		speed=slow \
>  			run_tests $ns1 $ns2 10.0.1.1 &
>  		local tests_pid=$!

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