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 8/8] selftests: mptcp: flush userspace addrs list
Date: Wed, 21 Feb 2024 17:21:01 +0100 [thread overview]
Message-ID: <360c8ee5-99c4-44b2-91f1-ebe634b19a2a@kernel.org> (raw)
In-Reply-To: <bb5e3f97c4a225f616d82112570514114fce00c5.1708497039.git.tanggeliang@kylinos.cn>
Hi Geliang,
On 21/02/2024 7:31 am, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> This patch adds a new helper userspace_pm_flush() to flush all addresses
> for the userspace PM. Invoke it in userspace pm dump address and subflow
> tests. And use dump commands to check if the userspace pm local address
> list is empty after addresses flushing.
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> .../testing/selftests/net/mptcp/mptcp_join.sh | 46 ++++++++++++++++---
> 1 file changed, 39 insertions(+), 7 deletions(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index aedc5698f26a..9f1476f0e2ae 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -3374,6 +3374,34 @@ userspace_pm_get_addr()
> ip netns exec $1 ./pm_nl_ctl get $2 token $tk
> }
>
> +# $1: ns ; $2: addr
> +userspace_pm_flush()
> +{
> + if mptcp_lib_kallsyms_has "mptcp_userspace_pm_dump_addr$"; then
> + local ns=$1
> + local line
> +
> + userspace_pm_dump $ns | while read -r line; do
This will create a subshell: it means that variables that are changed
here below will only be valid in this restricted scope. In other words,
if there is a failure below, the 'failure' message will be printed, but
'ret=1' will only be set here in this scope, so the test will not be
marked as failed: the check will be ignored. You cannot do it like that.
What you can do is something like that to avoid a subshell:
while read -r line; do (...); done <<< $(cmd)
but...
> + local arr=($line)
> + local nr=0
> + local id
> + local addr
> + local i
> + for i in "${arr[@]}"; do
> + if [ $i = "id" ]; then
> + id=${arr[$nr+1]}
> + fi
> + nr=$((nr + 1))
> + done
> + addr=${arr[$nr-1]}
Can you not use read to do the parsing if it is always the same output:
read -r _ id _ _ addr
> + userspace_pm_rm_addr $ns $id
> + userspace_pm_rm_sf $ns "$addr" $SUB_ESTABLISHED
> + done
> + else
> + print_skip
The skip doesn't make sense here: there is no 'check' in progress.
But that's not it, the behaviour is wrong too: if the feature is not
supported, it means that the subflows and addresses will not be removed,
then the rest of the test will be wrong on kernels not supporting the
features because the counters will be different.
Maybe we could do that in a new dedicated test where everything is
skipped if "dump addresses" is not supported. But, does this test
increase the code coverage? I understand that doing the flush is a good
"summary", but it looks like this has already been validated, no? So
maybe easier to drop this?
> + fi
> +}
> +
> userspace_pm_chk_dump_addr()
> {
> local ns="${1}"
(...)
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2024-02-21 16:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-21 6:31 [PATCH mptcp-next 0/8] some cleanups Geliang Tang
2024-02-21 6:31 ` [PATCH mptcp-next 1/8] mptcp: make pm_remove_addrs_and_subflows static Geliang Tang
2024-02-21 6:31 ` [PATCH mptcp-next 2/8] mptcp: drop duplicate header inclusions Geliang Tang
2024-02-21 6:31 ` [PATCH mptcp-next 3/8] mptcp: update set_flags interfaces Geliang Tang
2024-02-21 6:31 ` [PATCH mptcp-next 4/8] mptcp: set error messages for set_flags Geliang Tang
2024-02-21 16:18 ` Matthieu Baerts
2024-02-21 6:31 ` [PATCH mptcp-next 5/8] mptcp: drop lookup_by_id in lookup_addr Geliang Tang
2024-02-21 6:31 ` [PATCH mptcp-next 6/8] mptcp: add use_id parameter for addresses_equal Geliang Tang
2024-02-21 16:19 ` Matthieu Baerts
2024-02-21 6:31 ` [PATCH mptcp-next 7/8] mptcp: add check_id for lookup_anno_list_by_saddr Geliang Tang
2024-02-21 16:20 ` Matthieu Baerts
2024-02-21 6:31 ` [PATCH mptcp-next 8/8] selftests: mptcp: flush userspace addrs list Geliang Tang
2024-02-21 15:47 ` selftests: mptcp: flush userspace addrs list: Tests Results MPTCP CI
2024-02-21 16:21 ` Matthieu Baerts [this message]
2024-02-21 16:18 ` [PATCH mptcp-next 0/8] some cleanups 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=360c8ee5-99c4-44b2-91f1-ebe634b19a2a@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox