From: Geliang Tang <geliang@kernel.org>
To: Matthieu Baerts <matttbe@kernel.org>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v6 5/9] selftests: net: lib: remove ns from list after clean-up
Date: Tue, 28 May 2024 21:18:24 +0800 [thread overview]
Message-ID: <60d8e4dd2e8bb8671200bf009c7f49d9ec545cec.camel@kernel.org> (raw)
In-Reply-To: <a5f1ae57-009b-4a44-93a9-8bfd38ab672b@kernel.org>
On Tue, 2024-05-28 at 12:38 +0200, Matthieu Baerts wrote:
> Hi Geliang,
>
> Thank you for your review!
>
> On 28/05/2024 05:47, Geliang Tang wrote:
> > On Mon, 2024-05-27 at 12:58 +0200, Matthieu Baerts (NGI0) wrote:
> > > Instead of only appending items to the list, remove them when the
> > > netns
> > > has been deleted.
> > >
> > > By doing that, we can make sure 'cleanup_all_ns()' is not trying
> > > to
> > > remove already deleted netns.
> > >
> > > Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> > > ---
> > > tools/testing/selftests/net/lib.sh | 21 +++++++++++++++++----
> > > 1 file changed, 17 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/tools/testing/selftests/net/lib.sh
> > > b/tools/testing/selftests/net/lib.sh
> > > index b2572aff6286..c7a8cfb477cc 100644
> > > --- a/tools/testing/selftests/net/lib.sh
> > > +++ b/tools/testing/selftests/net/lib.sh
> > > @@ -125,6 +125,20 @@ slowwait_for_counter()
> > > slowwait "$timeout" until_counter_is ">= $((base +
> > > delta))"
> > > "$@"
> > > }
> > >
> > > +remove_ns_list()
> > > +{
> > > + local item=$1
> > > + local ns
> > > + local ns_list=("${NS_LIST[@]}")
> > > + NS_LIST=()
> > > +
> > > + for ns in "${ns_list[@]}"; do
> > > + if [ "${ns}" != "${item}" ]; then
> > > + NS_LIST+=("${ns}")
> > > + fi
> > > + done
> > > +}
> > > +
> > > cleanup_ns()
> > > {
> > > local ns=""
> > > @@ -136,6 +150,8 @@ cleanup_ns()
> > > if ! busywait $BUSYWAIT_TIMEOUT ip netns list \|
> > > grep -vq "^$ns$" &> /dev/null; then
> > > echo "Warn: Failed to remove namespace
> > > $ns"
> > > ret=1
> > > + else
> >
> > nit: Should we also remove ns_list when "ip netns list" is busy? Or
> > should we not delete ns when "ip netns list" is busy?
> >
> > I think we should do these two commands together:
> >
> > ip netns delete "${ns}" &> /dev/null || true
> > remove_ns_list "${ns}"
> >
> > I'm not sure. WDYT?
>
> Good point, I'm not sure either. I kept it in the list because in
> case
> of errors, the caller could still get the list of NS that have been
> created, but not deleted yet.
>
> To be honest, I don't think any actions should be done on the NS
> after
> having called cleanup: it would probably better to kill all attached
> processes before that, and not retry later after errors and a kill.
> But
> I didn't want to change this logic as there might be other impacts.
> So
> at least here, we let the responsibility to the caller, and it can
> call
> cleanup_all_ns() again in case of errors. WDYT?
If so, I think this is better:
for ns in "$@"; do
[ -z "${ns}" ] && continue
ip netns delete "${ns}" &> /dev/null || true
remove_ns_list "${ns}"
if ! busywait $BUSYWAIT_TIMEOUT ip netns list \| grep -
vq "^$ns$" &> /dev/null; then
echo "Warn: Failed to remove namespace $ns"
ret=1
fi
done
If you agree, please update this when merging it. No need to send a v7.
And please add my Reviewd-by tag. I'll repay it in the cover-letter.
Thanks,
-Geliang
>
> Cheers,
> Matt
next prev parent reply other threads:[~2024-05-28 13:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 10:58 [PATCH mptcp-next v6 0/9] use helpers in lib.sh and net_helpers.sh Matthieu Baerts (NGI0)
2024-05-27 10:58 ` [PATCH mptcp-next v6 1/9] selftests: net: lib: set 'i' as local Matthieu Baerts (NGI0)
2024-05-27 10:58 ` [PATCH mptcp-next v6 2/9] selftests: net: lib: support errexit with busywait Matthieu Baerts (NGI0)
2024-05-27 10:58 ` [PATCH mptcp-next v6 3/9] selftests: net: lib: avoid error removing empty netns name Matthieu Baerts (NGI0)
2024-05-27 10:58 ` [PATCH mptcp-next v6 4/9] selftests: net: lib: ignore possible error Matthieu Baerts (NGI0)
2024-05-27 10:58 ` [PATCH mptcp-next v6 5/9] selftests: net: lib: remove ns from list after clean-up Matthieu Baerts (NGI0)
2024-05-28 3:47 ` Geliang Tang
2024-05-28 10:38 ` Matthieu Baerts
2024-05-28 13:18 ` Geliang Tang [this message]
2024-05-28 15:26 ` Matthieu Baerts
2024-05-29 1:31 ` Geliang Tang
2024-05-27 10:58 ` [PATCH mptcp-next v6 6/9] selftests: net: lib: do not set ns var as readonly Matthieu Baerts (NGI0)
2024-05-27 10:58 ` [PATCH mptcp-next v6 7/9] selftests: net: lib: remove 'ns' var in setup_ns Matthieu Baerts (NGI0)
2024-05-27 10:58 ` [PATCH mptcp-next v6 8/9] selftests: mptcp: lib: use setup/cleanup_ns helpers Matthieu Baerts (NGI0)
2024-05-27 10:58 ` [PATCH mptcp-next v6 9/9] selftests: mptcp: lib: use wait_local_port_listen helper Matthieu Baerts (NGI0)
2024-05-27 11:47 ` [PATCH mptcp-next v6 0/9] use helpers in lib.sh and net_helpers.sh MPTCP CI
2024-05-28 13:19 ` Geliang Tang
2024-06-03 16:01 ` 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=60d8e4dd2e8bb8671200bf009c7f49d9ec545cec.camel@kernel.org \
--to=geliang@kernel.org \
--cc=matttbe@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox