From: Matthieu Baerts <matttbe@kernel.org>
To: Petr Machata <petrm@nvidia.com>, Breno Leitao <leitao@debian.org>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, Shuah Khan <shuah@kernel.org>,
netdev@vger.kernel.org, David Wei <dw@davidwei.uk>,
Willem de Bruijn <willemb@google.com>,
open list <linux-kernel@vger.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@vger.kernel.org>,
Geliang Tang <geliang@kernel.org>,
Hangbin Liu <liuhangbin@gmail.com>
Subject: Re: [PATCH net-next v2] net: netconsole: selftests: Create a new netconsole selftest
Date: Wed, 14 Aug 2024 13:31:50 +0200 [thread overview]
Message-ID: <af896c55-723e-4c2b-b153-132f863e2f68@kernel.org> (raw)
In-Reply-To: <87r0arl5qw.fsf@nvidia.com>
Hi Petr, Breno,
On 14/08/2024 12:24, Petr Machata wrote:
>
> Breno Leitao <leitao@debian.org> writes:
>
>> Adds a selftest that creates two virtual interfaces, assigns one to a
>> new namespace, and assigns IP addresses to both.
>>
>> It listens on the destination interface using socat and configures a
>> dynamic target on netconsole, pointing to the destination IP address.
>>
>> The test then checks if the message was received properly on the
>> destination interface.
(...)
>> diff --git a/tools/testing/selftests/drivers/net/netcons_basic.sh b/tools/testing/selftests/drivers/net/netcons_basic.sh
>> new file mode 100755
>> index 000000000000..e0e58fc7e89f
>> --- /dev/null
>> +++ b/tools/testing/selftests/drivers/net/netcons_basic.sh
>> @@ -0,0 +1,223 @@
(...)
> +NAMESPACE="netconsns_dst"
(...)
>> +function set_network() {
>> + # This is coming from lib.sh. And it does unbound variable access
>> + set +u
>> + setup_ns "${NAMESPACE}"
>> + set -u
>
> It would make sense to fix lib.sh. I think this is what is needed?
>
> modified tools/testing/selftests/net/lib.sh
> @@ -178,7 +178,7 @@ setup_ns()
> fi
>
> # Some test may setup/remove same netns multi times
> - if [ -z "${!ns_name}" ]; then
> + if ! declare -p "$ns_name" &> /dev/null; then
> eval "${ns_name}=${ns_name,,}-$(mktemp -u XXXXXX)"
> else
> cleanup_ns "${!ns_name}"
>
> CC'd Geliang Tang <geliang@kernel.org>, Hangbin Liu <liuhangbin@gmail.com>,
> Matthieu Baerts (NGI0) <matttbe@kernel.org> who were in the vicinity
> in the past.
Thank you for having CCed me.
I don't know if lib.sh needs to be modified: setup_ns() is supposed to
be called with the name of an existing variable. Can you not define this
variable before?
I mean: the modification from Petr looks good to me to support 'set -u',
but it sounds safer to define the variable before in the script, just in
case it is defined by in the environment, before starting the test, and
not taking the expected path.
Note that in all the other selftests, setup_ns() is called with the name
of the variable, not a variable like you did, e.g.
NAMESPACE=
setup_ns NAMESPACE
instead of:
NAMESPACE="netconsns_dst"
setup_ns "${NAMESPACE}"
NAMESPACE=${NS_LIST[0]}
Maybe better to do like the others?
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2024-08-14 11:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 18:38 [PATCH net-next v2] net: netconsole: selftests: Create a new netconsole selftest Breno Leitao
2024-08-13 22:37 ` Jakub Kicinski
2024-08-14 8:31 ` Breno Leitao
2024-08-14 10:24 ` Petr Machata
2024-08-14 11:31 ` Matthieu Baerts [this message]
2024-08-14 16:07 ` Breno Leitao
2024-08-15 7:56 ` Hangbin Liu
2024-08-15 8:15 ` Breno Leitao
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=af896c55-723e-4c2b-b153-132f863e2f68@kernel.org \
--to=matttbe@kernel.org \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=geliang@kernel.org \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=liuhangbin@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=shuah@kernel.org \
--cc=willemb@google.com \
/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