All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: Geliang Tang <geliang.tang@suse.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v2 3/3] selftests: mptcp: add backup with port testcase
Date: Thu, 13 Jan 2022 17:13:30 -0800 (PST)	[thread overview]
Message-ID: <d764977-66a3-7a8-ab81-81b8994641ea@linux.intel.com> (raw)
In-Reply-To: <7472cf13c155c5d37e6faba42d00dfa8ea4fe08b.1642085750.git.geliang.tang@suse.com>

On Thu, 13 Jan 2022, Geliang Tang wrote:

> This patch added the backup testcase using an address with a port number.
>
> The original backup tests only work for the output of 'pm_nl_ctl dump'
> without the port number. It chooses the last item in the dump to parse
> the address in it, and in this case, the address is showed at the end
> of the item.
>
> But it dosen't work for the dump with the port number, in this case, the
> port number is showed at the end of the item, not the address.
>
> This patch implemented a more flexible approach to get the address and
> the port number from the dump to fit for the port number case.
>
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> .../testing/selftests/net/mptcp/mptcp_join.sh | 46 +++++++++++++++++--
> 1 file changed, 41 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 25725be98342..39dffde68ae2 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -239,6 +239,16 @@ is_v6()
> 	[ -z "${1##*:*}" ]
> }
>
> +is_addr()
> +{
> +	[ -z "${1##*[.:]*}" ]
> +}
> +
> +is_number()
> +{
> +	[[ $1 == ?(-)+([0-9]) ]]
> +}
> +
> # $1: ns, $2: port
> wait_local_port_listen()
> {
> @@ -464,11 +474,27 @@ do_transfer()
> 	if [ ! -z $sflags ]; then
> 		sleep 1
> 		for netns in "$ns1" "$ns2"; do
> -			dump=(`ip netns exec $netns ./pm_nl_ctl dump`)
> -			if [ ${#dump[@]} -gt 0 ]; then
> -				addr=${dump[${#dump[@]} - 1]}
> -				ip netns exec $netns ./pm_nl_ctl set $addr flags $sflags
> -			fi
> +			ip netns exec $netns ./pm_nl_ctl dump | while read line; do
> +				local arr=($line)
> +				local addr
> +				local port=0
> +				local _port=""
> +
> +				for i in ${arr[@]}; do
> +					if is_addr $i; then
> +						addr=$i
> +					fi
> +					if is_number $i; then
> +						if [ $i -gt 10000 ]; then

Why this check for > 10000? I assume it's because the expected port 
numbers are assumed to be 10000+$TEST_COUNT but it would help to explain 
in a comment.

-Mat

> +							port=$i
> +						fi
> +					fi
> +				done
> +				if [ $port -gt 0 ]; then
> +					_port="port $port"
> +				fi
> +				ip netns exec $netns ./pm_nl_ctl set $addr flags $sflags $_port
> +			done
> 		done
> 	fi
>
> @@ -1651,6 +1677,16 @@ backup_tests()
> 	chk_add_nr 1 1
> 	chk_prio_nr 1 0
> 	chk_rm_nr 0 0
> +
> +	# single address with port, backup
> +	reset
> +	ip netns exec $ns1 ./pm_nl_ctl limits 0 1
> +	ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100
> +	ip netns exec $ns2 ./pm_nl_ctl limits 1 1
> +	run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup
> +	chk_join_nr "single address with port, backup" 1 1 1
> +	chk_add_nr 1 1
> +	chk_prio_nr 1 0
> }
>
> add_addr_ports_tests()
> -- 
> 2.31.1
>
>
>

--
Mat Martineau
Intel

  reply	other threads:[~2022-01-14  1:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13 15:08 [PATCH mptcp-next v2 0/3] set_flags port support Geliang Tang
2022-01-13 15:08 ` [PATCH mptcp-next v2 1/3] mptcp: allow to use port and non-signal in set_flags Geliang Tang
2022-01-13 15:08 ` [PATCH mptcp-next v2 2/3] selftests: mptcp: add the port argument for set_flags Geliang Tang
2022-01-13 15:08 ` [PATCH mptcp-next v2 3/3] selftests: mptcp: add backup with port testcase Geliang Tang
2022-01-14  1:13   ` Mat Martineau [this message]
2022-01-13 15:08 ` [PATCH mptcp-next v5 0/5] use 'ip mptcp' in selftests Geliang Tang
2022-01-13 15:08   ` [PATCH mptcp-next v5 1/5] selftests: mptcp: add ip mptcp wrappers Geliang Tang
2022-01-13 15:08   ` [PATCH mptcp-next v5 2/5] selftests: mptcp: new approach of getting ID Geliang Tang
2022-01-13 15:08   ` [PATCH mptcp-next v5 3/5] selftests: mptcp: add wrapper for showing addrs Geliang Tang
2022-01-13 15:08   ` [PATCH mptcp-next v5 4/5] selftests: mptcp: add wrapper for setting flags Geliang Tang
2022-01-14  1:22     ` Mat Martineau
2022-01-13 15:08   ` [PATCH mptcp-next v5 5/5] selftests: mptcp: set ip_mptcp in command line Geliang Tang
2022-01-14  1:27   ` [PATCH mptcp-next v5 0/5] use 'ip mptcp' in selftests 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=d764977-66a3-7a8-ab81-81b8994641ea@linux.intel.com \
    --to=mathew.j.martineau@linux.intel.com \
    --cc=geliang.tang@suse.com \
    --cc=mptcp@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.