All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthieu Baerts <matttbe@kernel.org>
To: Geliang Tang <geliang@kernel.org>, mptcp@lists.linux.dev
Cc: Geliang Tang <tanggeliang@kylinos.cn>
Subject: Re: [PATCH mptcp-next v4 3/9] selftests: mptcp: add get_endpoint helper
Date: Tue, 19 Mar 2024 17:59:50 +0100	[thread overview]
Message-ID: <b02edbef-2910-4e50-b9ea-f236f262d2dc@kernel.org> (raw)
In-Reply-To: <95b2607b75ac0225a4bff3d863d786b7a0db999b.1710832493.git.tanggeliang@kylinos.cn>

Hi Geliang,

On 19/03/2024 08:16, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> The output formats of 'ip mptcp' commands are much different from that
> of 'pm_nl_ctl' commands. This patch adds a new helper format_endpoints()
> to format the outputs of 'ip mptcp' and 'pm_nl_ctl' with 'endpoints'
> arguments to hide these differences.
> 
> All endpoints are showed in show_endpoints(). Here add another helper
> named get_endpoint() to show a specofic endpoint identified by the given

s/specofic/specific

> address ID.
> 
> Usage:
> 	All endpoints - show_endpoints $ns
> 	One endpoint - get_endpoint $ns $id

It is a bit confusing, you didn't add 'show_endpoints', maybe you are
talking about 'pm_nl_show_endpoints' from mptcp_join.sh? But there is
nothing about mptcp_lib_pm_nl_format_endpoints().

> 
> Use these two helpers in mptcp_join.sh and pm_netlink.sh to replace all
> 'pm_nl_ctl get' commands and outputs of 'pm_nl_ctl dump/get'.

(...)

> diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> index ca01d949fad8..ceb8f272c69d 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> @@ -520,3 +520,37 @@ mptcp_lib_set_ip_mptcp() {
>  mptcp_lib_is_ip_mptcp() {
>  	[ "${MPTCP_LIB_IP_MPTCP}" = "1" ]
>  }
> +
> +# format: <id>,<ip>,<flags>,<dev>
> +mptcp_lib_pm_nl_format_endpoints() {
> +	local entry id ip flags dev port
> +
> +	for entry in "${@}"; do
> +		IFS=, read -r id ip flags dev port <<< "${entry}"
> +		if mptcp_lib_is_ip_mptcp; then
> +			echo -n "${ip}"
> +			[ -n "${port}" ] && echo -n " port ${port}"
> +			echo -n " id ${id}"
> +			[ -n "${flags}" ] && echo -n " ${flags}"
> +			[ -n "${dev}" ] && echo -n " dev ${dev}"
> +			echo " " # always a space at the end
> +		else
> +			echo -n "id ${id}"
> +			echo -n " flags ${flags//" "/","}"
> +			[ -n "${dev}" ] && echo -n " dev ${dev}"
> +			echo -n " ${ip}"
> +			[ -n "${port}" ] && echo " ${port}" || echo ""

detail: maybe easier to read with:

  [ -n "${port}" ] && echo -n " ${port}"
  echo

> +		fi
> +	done
> +}
> +
> +mptcp_lib_pm_nl_get_endpoint() {
> +	local ns=${1}
> +	local id=${2}
> +
> +	if mptcp_lib_is_ip_mptcp; then
> +		ip -n "${ns}" mptcp endpoint show id "${id}"
> +	else
> +		ip netns exec "${ns}" ./pm_nl_ctl get "${id}"
> +	fi
> +}
Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


  reply	other threads:[~2024-03-19 16:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-19  7:16 [PATCH mptcp-next v4 0/9] add helpers and vars in mptcp_lib.sh, final Geliang Tang
2024-03-19  7:16 ` [PATCH mptcp-next v4 1/9] selftests: mptcp: export ip_mptcp to mptcp_lib Geliang Tang
2024-03-19  7:16 ` [PATCH mptcp-next v4 2/9] selftests: mptcp: add get_limits helper Geliang Tang
2024-03-19 16:58   ` Matthieu Baerts
2024-03-19  7:16 ` [PATCH mptcp-next v4 3/9] selftests: mptcp: add get_endpoint helper Geliang Tang
2024-03-19 16:59   ` Matthieu Baerts [this message]
2024-03-19  7:16 ` [PATCH mptcp-next v4 4/9] selftests: mptcp: add change_address helper Geliang Tang
2024-03-19 17:01   ` Matthieu Baerts
2024-03-19  7:16 ` [PATCH mptcp-next v4 5/9] selftests: mptcp: join: update endpoint ops Geliang Tang
2024-03-19  7:16 ` [PATCH mptcp-next v4 6/9] selftests: mptcp: export pm_nl " Geliang Tang
2024-03-19  7:16 ` [PATCH mptcp-next v4 7/9] selftests: mptcp: use " Geliang Tang
2024-03-19  7:16 ` [PATCH mptcp-next v4 8/9] selftests: mptcp: ip_mptcp option for more scripts Geliang Tang
2024-03-19  7:16 ` [PATCH mptcp-next v4 9/9] selftests: mptcp: netlink: drop disable=SC2086 Geliang Tang
2024-03-19  8:07 ` [PATCH mptcp-next v4 0/9] add helpers and vars in mptcp_lib.sh, final MPTCP CI
2024-03-19 16:58 ` Matthieu Baerts
2024-03-19 17:43   ` 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=b02edbef-2910-4e50-b9ea-f236f262d2dc@kernel.org \
    --to=matttbe@kernel.org \
    --cc=geliang@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=tanggeliang@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.