From: Geliang Tang <geliang@kernel.org>
To: Matthieu Baerts <matttbe@kernel.org>, mptcp@lists.linux.dev
Cc: Geliang Tang <tanggeliang@kylinos.cn>
Subject: Re: [PATCH mptcp-next v2 2/4] selftests: mptcp: use setup_ns helper in lib.sh
Date: Thu, 23 May 2024 17:26:40 +0800 [thread overview]
Message-ID: <ee6ae6878137687a0734cd7ea6767a86a8fb21a3.camel@kernel.org> (raw)
In-Reply-To: <4fe52b77-75af-42ff-9079-fc61fb2509d8@kernel.org>
Hi Matt,
On Thu, 2024-05-23 at 11:18 +0200, Matthieu Baerts wrote:
> Hi Geliang,
>
> On 23/05/2024 10:08, Geliang Tang wrote:
> > From: Geliang Tang <tanggeliang@kylinos.cn>
> >
> > This patch includes lib.sh into mptcp_lib.sh, uses setup_ns()
> > helper
> > defined in lib.sh to set up namespaces in mptcp_lib_ns_init(). Then
> > for
> > each namespace in NS_LIST, run all sysctl commands. This can drop
> > some
> > duplicate code.
> >
> > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> > ---
> > .../testing/selftests/net/mptcp/mptcp_lib.sh | 19 +++++++--------
> > ----
> > 1 file changed, 7 insertions(+), 12 deletions(-)
> >
> > diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> > b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> > index ad2ebda5cb64..59eb77e7813d 100644
> > --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> > +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
>
>
> (...)
>
> > @@ -412,20 +414,13 @@ mptcp_lib_check_tools() {
> > }
> >
> > mptcp_lib_ns_init() {
> > - local sec rndh
> > -
> > - sec=$(date +%s)
> > - rndh=$(printf %x "${sec}")-$(mktemp -u XXXXXX)
> > + setup_ns "${@}"
> >
> > local netns
> > - for netns in "${@}"; do
> > - eval "${netns}=${netns}-${rndh}"
> > -
> > - ip netns add "${!netns}" || exit ${KSFT_SKIP}
> > - ip -net "${!netns}" link set lo up
> > - ip netns exec "${!netns}" sysctl -q
> > net.mptcp.enabled=1
> > - ip netns exec "${!netns}" sysctl -q
> > net.ipv4.conf.all.rp_filter=0
> > - ip netns exec "${!netns}" sysctl -q
> > net.ipv4.conf.default.rp_filter=0
> > + for netns in $NS_LIST; do
>
> Could you add {} (${NS_LIST}), to keep the same style (and usually
> recommended in order to avoid typos, etc.)
>
> Also, I wonder if it is a good idea to use '${NS_LIST}': it might
> contain existing netns. e.g. with your patch 3/4, in mptcp_connect,
> mptcp_lib_ns_init will be called twice, modifying the first netns
> twice.
>
> What if you keep:
>
> for netns in "${@}"; do
>
> and use "${!netns}" instead?
We don't know the name of ns now because "mktemp -u XXXXXX" is executed
within setup_ns(). So we have to use $NS_LIST.
>
>
> > + ip netns exec "${netns}" sysctl -q
> > net.mptcp.enabled=1
> > + ip netns exec "${netns}" sysctl -q
> > net.ipv4.conf.all.rp_filter=0
> > + ip netns exec "${netns}" sysctl -q
> > net.ipv4.conf.default.rp_filter=0
> > done
> > }
> >
>
> Cheers,
> Matt
next prev parent reply other threads:[~2024-05-23 9:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 8:08 [PATCH mptcp-next v2 0/4] use helpers in lib.sh and net_helpers.sh Geliang Tang
2024-05-23 8:08 ` [PATCH mptcp-next v2 1/4] selftests: mptcp: rename ns to ns1 in diag.sh Geliang Tang
2024-05-23 9:14 ` Matthieu Baerts
2024-05-23 8:08 ` [PATCH mptcp-next v2 2/4] selftests: mptcp: use setup_ns helper in lib.sh Geliang Tang
2024-05-23 9:18 ` Matthieu Baerts
2024-05-23 9:26 ` Geliang Tang [this message]
2024-05-23 9:34 ` Matthieu Baerts
2024-05-23 8:08 ` [PATCH mptcp-next v2 3/4] selftests: mptcp: use cleanup_all_ns " Geliang Tang
2024-05-23 8:39 ` Geliang Tang
2024-05-23 9:22 ` Matthieu Baerts
2024-05-23 8:09 ` [PATCH mptcp-next v2 4/4] selftests: mptcp: use wait_local_port_listen helper Geliang Tang
2024-05-23 9:24 ` Matthieu Baerts
2024-05-23 8:58 ` [PATCH mptcp-next v2 0/4] use helpers in lib.sh and net_helpers.sh MPTCP CI
2024-05-23 9:13 ` 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=ee6ae6878137687a0734cd7ea6767a86a8fb21a3.camel@kernel.org \
--to=geliang@kernel.org \
--cc=matttbe@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