From: Matthieu Baerts <matttbe@kernel.org>
To: Gang Yan <yangang@kylinos.cn>, mptcp@lists.linux.dev
Cc: Geliang Tang <geliang@kernel.org>
Subject: Re: [mptcp-next v2 7/7] selftests: mptcp: add chk_sublfow in diag.sh
Date: Tue, 22 Apr 2025 15:24:48 +0200 [thread overview]
Message-ID: <6bfa23c9-fdcb-49c1-a808-887dff760205@kernel.org> (raw)
In-Reply-To: <6be98516e035e73e9523e4fb8c301bc482e65133.1744793332.git.yangang@kylinos.cn>
On 16/04/2025 10:59, Gang Yan wrote:
> This patch aims to add chk_dump_subflow in diag.sh. The subflow's
> info can be obtained through "ss -tin", then use the 'mptcp_diag'
> to verify the token in subflow_info.
>
> Co-developed-by: Geliang Tang <geliang@kernel.org>
> Signed-off-by: Geliang Tang <geliang@kernel.org>
> Signed-off-by: Gang Yan <yangang@kylinos.cn>
> ---
> tools/testing/selftests/net/mptcp/diag.sh | 55 +++++++++++++++++++++++
> 1 file changed, 55 insertions(+)
>
> diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
> index e7a75341f0f3..20de007e44cd 100755
> --- a/tools/testing/selftests/net/mptcp/diag.sh
> +++ b/tools/testing/selftests/net/mptcp/diag.sh
> @@ -225,6 +225,60 @@ chk_dump_one()
> fi
> }
>
> +get_endpoint_addr()
> +{
> + echo $1 | cut -d ":" -f 1
> +}
> +
> +get_endpoint_port()
> +{
> + echo $1 | cut -d ":" -f 2
> +}
> +
> +chk_dump_subflow()
> +{
> + local inet_diag_token
> + local subflow_line
> + local remote_addr
> + local remote_port
> + local local_addr
> + local local_port
> + local ss_token
> + local msg
> +
> + subflow_line=$(ss -tnN $ns | \
> + grep -m1 -Eo '[0-9.]+:[0-9].+ +[0-9.]+:[0-9.]+')
> +
> + if [ -n "$subflow_line" ]; then
> + read -r local_endpoint remote_endpoint <<< $subflow_line
> +
> + local_addr=$(get_endpoint_addr $local_endpoint)
> + local_port=$(get_endpoint_port $local_endpoint)
(you could use 'read -rd: local_addr local_port' here ; same below)
> +
> + remote_addr=$(get_endpoint_addr $remote_endpoint)
> + remote_port=$(get_endpoint_port $remote_endpoint)
> + fi
> +
> + ss_token=$(ss -tniN $ns | \
> + grep -m1 -Eo 'token:[^ ]+')
It might be safer to call 'ss' only once, then extract the subflow and
the ports later.
> +
> + inet_diag_token=$(ip netns exec $ns ./mptcp_diag -s \
> + "$local_addr $local_port $remote_addr $remote_port" | \
Why don't you call 'mptcp_diag -s "$subflow_line"', then adapt sscanf in
mptcp_diag.c to use: "%s:%d %s:%d"?
You will save a few lines of bash here above by doing that. Or is it
more difficult when handling IPv6 addresses? I don't think you handle
IPv6 addresses anyway, right?
> + grep -Eo 'token:[^ ]+')
> +
> + msg="....chk dump_subflow"
> +
> + mptcp_lib_print_title "$msg"
> + if [[ $ss_token == $inet_diag_token ]]; then
Please use the same style as elsewhere in the file:
if [ -n "$ss_token" ] && [ "$ss_token" = "$inet_diag_token" ]; then
> + mptcp_lib_pr_ok
> + mptcp_lib_result_pass "${msg}"
> + else
> + mptcp_lib_pr_fail "expected $ss_token but $inet_diag_token"
Same here for the style:
"expected $ss_token found $inet_diag_token"
> + mptcp_lib_result_fail "${msg}"
> + ret=${KSFT_FAIL}
> + fi
> +}
> +
> msk_info_get_value()
> {
> local port="${1}"
> @@ -316,6 +370,7 @@ chk_msk_fallback_nr 0 "....chk no fallback"
> chk_msk_inuse 2
> chk_msk_cestab 2
> chk_dump_one
> +chk_dump_subflow
> flush_pids
>
> chk_msk_inuse 0 "2->0"
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2025-04-22 13:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 8:59 [mptcp-next v2 0/7] Add 'dump_subflow' test in selftests Gang Yan
2025-04-16 8:59 ` [mptcp-next v2 1/7] selftests: mptcp: add struct params in mptcp_diag Gang Yan
2025-04-16 8:59 ` [mptcp-next v2 2/7] selftests: mptcp: refactor send_query parameters for code clarity Gang Yan
2025-04-22 13:22 ` Matthieu Baerts
2025-04-16 8:59 ` [mptcp-next v2 3/7] selftests: mptcp: refine the 'iovlen' handling logic Gang Yan
2025-04-22 13:22 ` Matthieu Baerts
2025-04-16 8:59 ` [mptcp-next v2 4/7] selftests: mptcp: refactor NLMSG handling with 'proto' Gang Yan
2025-04-16 8:59 ` [mptcp-next v2 5/7] selftests: mptcp: add a helper to get subflow_info Gang Yan
2025-04-22 13:23 ` Matthieu Baerts
2025-04-16 8:59 ` [mptcp-next v2 6/7] selftests: mptcp: add a helper to print subflow_info Gang Yan
2025-04-22 13:23 ` Matthieu Baerts
2025-04-16 8:59 ` [mptcp-next v2 7/7] selftests: mptcp: add chk_sublfow in diag.sh Gang Yan
2025-04-22 13:24 ` Matthieu Baerts [this message]
2025-04-16 10:20 ` [mptcp-next v2 0/7] Add 'dump_subflow' test in selftests MPTCP CI
2025-04-22 13:22 ` Matthieu Baerts
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=6bfa23c9-fdcb-49c1-a808-887dff760205@kernel.org \
--to=matttbe@kernel.org \
--cc=geliang@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=yangang@kylinos.cn \
/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.