netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geliang Tang <geliang.tang@suse.com>
To: Mat Martineau <martineau@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, mptcp@lists.linux.dev
Subject: Re: [PATCH net-next v3 03/15] selftests: mptcp: add chk_subflows_total helper
Date: Sat, 18 Nov 2023 11:09:16 +0800	[thread overview]
Message-ID: <20231118030916.GA3271@bogon> (raw)
In-Reply-To: <20231115-send-net-next-2023107-v3-3-1ef58145a882@kernel.org>

Hi Mat,

On Wed, Nov 15, 2023 at 04:31:31PM -0800, Mat Martineau wrote:
> From: Geliang Tang <geliang.tang@suse.com>
> 
> This patch adds a new helper chk_subflows_total(), in it use the newly
> added counter mptcpi_subflows_total to get the "correct" amount of
> subflows, including the initial one.
> 
> To be compatible with old 'ss' or kernel versions not supporting this
> counter, get the total subflows by listing TCP connections that are
> MPTCP subflows:
> 
>     ss -ti state state established state syn-sent state syn-recv |
>         grep -c tcp-ulp-mptcp.
> 
> Reviewed-by: Matthieu Baerts <matttbe@kernel.org>
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> Signed-off-by: Mat Martineau <martineau@kernel.org>
> ---
>  tools/testing/selftests/net/mptcp/mptcp_join.sh | 41 ++++++++++++++++++++++++-
>  1 file changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index f064803071f1..2130e3b7790f 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -1867,7 +1867,7 @@ chk_mptcp_info()
>  	local cnt2
>  	local dump_stats
>  
> -	print_check "mptcp_info ${info1:0:8}=$exp1:$exp2"
> +	print_check "mptcp_info ${info1:0:15}=$exp1:$exp2"
>  
>  	cnt1=$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value "$info1" "$info1")
>  	cnt2=$(ss -N $ns2 -inmHM | mptcp_lib_get_info_value "$info2" "$info2")
> @@ -1888,6 +1888,41 @@ chk_mptcp_info()
>  	fi
>  }
>  
> +# $1: subflows in ns1 ; $2: subflows in ns2
> +# number of all subflows, including the initial subflow.
> +chk_subflows_total()
> +{
> +	local cnt1
> +	local cnt2
> +	local info="subflows_total"

Sorry, this line should be added here:

	local dump_stats

Otherwise, no place to set 0 to dump_stats, if a test fails. Then
unexpected dump infos will be showed in all the subsequent outputs
of chk_subflows_total().

I'll send a squash-to patch to fix this.

Thanks,
-Geliang


> +
> +	# if subflows_total counter is supported, use it:
> +	if [ -n "$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value $info $info)" ]; then
> +		chk_mptcp_info $info $1 $info $2
> +		return
> +	fi
> +
> +	print_check "$info $1:$2"
> +
> +	# if not, count the TCP connections that are in fact MPTCP subflows
> +	cnt1=$(ss -N $ns1 -ti state established state syn-sent state syn-recv |
> +	       grep -c tcp-ulp-mptcp)
> +	cnt2=$(ss -N $ns2 -ti state established state syn-sent state syn-recv |
> +	       grep -c tcp-ulp-mptcp)
> +
> +	if [ "$1" != "$cnt1" ] || [ "$2" != "$cnt2" ]; then
> +		fail_test "got subflows $cnt1:$cnt2 expected $1:$2"
> +		dump_stats=1
> +	else
> +		print_ok
> +	fi
> +
> +	if [ "$dump_stats" = 1 ]; then
> +		ss -N $ns1 -ti
> +		ss -N $ns2 -ti
> +	fi
> +}
> +
>  chk_link_usage()
>  {
>  	local ns=$1
> @@ -3431,10 +3466,12 @@ userspace_tests()
>  		chk_join_nr 1 1 1
>  		chk_add_nr 1 1
>  		chk_mptcp_info subflows 1 subflows 1
> +		chk_subflows_total 2 2
>  		chk_mptcp_info add_addr_signal 1 add_addr_accepted 1
>  		userspace_pm_rm_sf_addr_ns1 10.0.2.1 10
>  		chk_rm_nr 1 1 invert
>  		chk_mptcp_info subflows 0 subflows 0
> +		chk_subflows_total 1 1
>  		kill_events_pids
>  		wait $tests_pid
>  	fi
> @@ -3451,9 +3488,11 @@ userspace_tests()
>  		userspace_pm_add_sf 10.0.3.2 20
>  		chk_join_nr 1 1 1
>  		chk_mptcp_info subflows 1 subflows 1
> +		chk_subflows_total 2 2
>  		userspace_pm_rm_sf_addr_ns2 10.0.3.2 20
>  		chk_rm_nr 1 1
>  		chk_mptcp_info subflows 0 subflows 0
> +		chk_subflows_total 1 1
>  		kill_events_pids
>  		wait $tests_pid
>  	fi
> 
> -- 
> 2.41.0
> 

  reply	other threads:[~2023-11-18  3:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16  0:31 [PATCH net-next v3 00/15] mptcp: More selftest coverage and code cleanup for net-next Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 01/15] mptcp: add mptcpi_subflows_total counter Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 02/15] selftests: mptcp: add evts_get_info helper Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 03/15] selftests: mptcp: add chk_subflows_total helper Mat Martineau
2023-11-18  3:09   ` Geliang Tang [this message]
2023-11-16  0:31 ` [PATCH net-next v3 04/15] selftests: mptcp: update userspace pm test helpers Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 05/15] selftests: mptcp: userspace pm create id 0 subflow Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 06/15] mptcp: userspace pm rename remove_err to out Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 07/15] selftests: mptcp: userspace pm remove initial subflow Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 08/15] selftests: mptcp: userspace pm send RM_ADDR for ID 0 Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 09/15] selftests: mptcp: add mptcp_lib_kill_wait Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 10/15] selftests: mptcp: add mptcp_lib_is_v6 Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 11/15] selftests: mptcp: add mptcp_lib_get_counter Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 12/15] selftests: mptcp: add missing oflag=append Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 13/15] selftests: mptcp: add mptcp_lib_make_file Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 14/15] selftests: mptcp: add mptcp_lib_check_transfer Mat Martineau
2023-11-16  0:31 ` [PATCH net-next v3 15/15] selftests: mptcp: add mptcp_lib_wait_local_port_listen Mat Martineau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231118030916.GA3271@bogon \
    --to=geliang.tang@suse.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=martineau@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).