* [Discuss] Seeking advice on net selftests netns naming method
@ 2023-11-14 9:55 Hangbin Liu
2023-11-14 11:02 ` Paolo Abeni
0 siblings, 1 reply; 5+ messages in thread
From: Hangbin Liu @ 2023-11-14 9:55 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Jakub Kicinski, Eric Dumazet, Paolo Abeni,
Shuah Khan, David Ahern, linux-kselftest, Po-Hsu Lin,
Guillaume Nault
Hi,
Good day! Following Guillaume's suggestion, I've been working on updating all
net self-tests to run in their respective netns. This modification allows us
to execute all tests in parallel, potentially saving a significant amount of
test time.
However, I've encountered a challenge while making these modifications. The
net selftest folder contains around 80 tests (excluding the forwarding test),
with some tests using common netns names and others using self-defined names.
I've considered two methods to address this issue:
One approach is to retain the original names but append a unique suffix using
$(mktemp -u XXXXXX). While this is a straightforward solution, it may not
prevent future tests from using common names.
Another option is to establish a general netns lib. Similar to the NUM_NETIFS
variable in the forwarding test, we could introduce a variable like NUM_NS.
This variable would define the number of netns instances, and all tests would
use the netns lib to set up and clean up netns accordingly. However, this
approach might complicate test debugging, especially for tests like
fib_nexthops.sh, which relies on clear and visually netns names
(e.g., me/peer/remote).
I'm reaching out to gather your insights on this matter. Do you have any
suggestions or preferences regarding the two proposed methods, or do you have
an alternative solution in mind?
Your expertise in this area would be greatly appreciated.
Best Regards
Hangbin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Discuss] Seeking advice on net selftests netns naming method
2023-11-14 9:55 [Discuss] Seeking advice on net selftests netns naming method Hangbin Liu
@ 2023-11-14 11:02 ` Paolo Abeni
2023-11-15 7:51 ` Hangbin Liu
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2023-11-14 11:02 UTC (permalink / raw)
To: Hangbin Liu, netdev
Cc: David S. Miller, Jakub Kicinski, Eric Dumazet, Shuah Khan,
David Ahern, linux-kselftest, Po-Hsu Lin, Guillaume Nault
On Tue, 2023-11-14 at 17:55 +0800, Hangbin Liu wrote:
> Good day! Following Guillaume's suggestion, I've been working on updating all
> net self-tests to run in their respective netns. This modification allows us
> to execute all tests in parallel, potentially saving a significant amount of
> test time.
>
> However, I've encountered a challenge while making these modifications. The
> net selftest folder contains around 80 tests (excluding the forwarding test),
> with some tests using common netns names and others using self-defined names.
> I've considered two methods to address this issue:
>
> One approach is to retain the original names but append a unique suffix using
> $(mktemp -u XXXXXX). While this is a straightforward solution, it may not
> prevent future tests from using common names.
>
> Another option is to establish a general netns lib. Similar to the NUM_NETIFS
> variable in the forwarding test, we could introduce a variable like NUM_NS.
> This variable would define the number of netns instances, and all tests would
> use the netns lib to set up and clean up netns accordingly. However, this
> approach might complicate test debugging, especially for tests like
> fib_nexthops.sh, which relies on clear and visually netns names
> (e.g., me/peer/remote).
I personally would like sort of both :) e.g. lib function(s) to
automatically create and dispose netns, and retain a script-
specific/related name prefix.
The library function could optionally set the newly created namespaces
name in global variables provided by the caller, e.g.:
# create 3 namespaces:
netns_init 3
# create 3 namespaces and set the global variables:
# $remote, $local $me
# to their respective names
netns_init 3 remote local me
The trick to do such assignment would be using the 'eval' statement,
something alike
netns_init()
{
# create the netns
shift
while [ -n "$1" ]; do
eval $1=$NETNS_NAMES[0]
shift
done
}
While at that, it would be useful to package some common helper e.g. to
wait for a (tcp) listener to be created (available) on a given port.
WDYT?
Thanks!
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Discuss] Seeking advice on net selftests netns naming method
2023-11-14 11:02 ` Paolo Abeni
@ 2023-11-15 7:51 ` Hangbin Liu
2023-11-15 9:10 ` Paolo Abeni
0 siblings, 1 reply; 5+ messages in thread
From: Hangbin Liu @ 2023-11-15 7:51 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, David S. Miller, Jakub Kicinski, Eric Dumazet, Shuah Khan,
David Ahern, linux-kselftest, Po-Hsu Lin, Guillaume Nault
On Tue, Nov 14, 2023 at 12:02:00PM +0100, Paolo Abeni wrote:
> I personally would like sort of both :) e.g. lib function(s) to
> automatically create and dispose netns, and retain a script-
> specific/related name prefix.
>
> The library function could optionally set the newly created namespaces
> name in global variables provided by the caller, e.g.:
>
> # create 3 namespaces:
> netns_init 3
>
> # create 3 namespaces and set the global variables:
> # $remote, $local $me
> # to their respective names
> netns_init 3 remote local me
>
> The trick to do such assignment would be using the 'eval' statement,
> something alike
>
> netns_init()
> {
> # create the netns
>
> shift
> while [ -n "$1" ]; do
> eval $1=$NETNS_NAMES[0]
> shift
> done
> }
>
> While at that, it would be useful to package some common helper e.g. to
> wait for a (tcp) listener to be created (available) on a given port.
>
> WDYT?
Thanks, this is a good idea. I reviewed all the test cases and it should works
for most of them. Only the SRv6 tests are a little complex as they use 2 id
number for netns name. e.g. the setup_hs() in
srv6_end_dt46_l3vpn_test.sh. I plan to add the tmp string between the hs/rt and
ids. e.g. hs-xxxxxx-t100-1, rt-xxxxxx-1. I will have a try first.
Cheers
Hangbin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Discuss] Seeking advice on net selftests netns naming method
2023-11-15 7:51 ` Hangbin Liu
@ 2023-11-15 9:10 ` Paolo Abeni
2023-11-15 9:35 ` Hangbin Liu
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2023-11-15 9:10 UTC (permalink / raw)
To: Hangbin Liu, David Ahern, Stephen Hemminger
Cc: netdev, David S. Miller, Jakub Kicinski, Eric Dumazet, Shuah Khan,
David Ahern, linux-kselftest, Po-Hsu Lin, Guillaume Nault
On Wed, 2023-11-15 at 15:51 +0800, Hangbin Liu wrote:
> On Tue, Nov 14, 2023 at 12:02:00PM +0100, Paolo Abeni wrote:
> > I personally would like sort of both :) e.g. lib function(s) to
> > automatically create and dispose netns, and retain a script-
> > specific/related name prefix.
> >
> > The library function could optionally set the newly created namespaces
> > name in global variables provided by the caller, e.g.:
> >
> > # create 3 namespaces:
> > netns_init 3
> >
> > # create 3 namespaces and set the global variables:
> > # $remote, $local $me
> > # to their respective names
> > netns_init 3 remote local me
> >
> > The trick to do such assignment would be using the 'eval' statement,
> > something alike
> >
> > netns_init()
> > {
> > # create the netns
> >
> > shift
> > while [ -n "$1" ]; do
> > eval $1=$NETNS_NAMES[0]
> > shift
> > done
> > }
> >
> > While at that, it would be useful to package some common helper e.g. to
> > wait for a (tcp) listener to be created (available) on a given port.
> >
> > WDYT?
>
> Thanks, this is a good idea. I reviewed all the test cases and it should works
> for most of them. Only the SRv6 tests are a little complex as they use 2 id
> number for netns name. e.g. the setup_hs() in
> srv6_end_dt46_l3vpn_test.sh. I plan to add the tmp string between the hs/rt and
> ids. e.g. hs-xxxxxx-t100-1, rt-xxxxxx-1. I will have a try first.
Supposing netns_init() creates a namespace named <unique>, I think the
following (very hackish thing) would work:
# create an alias for the namespace
ln -s /var/run/netns/<unique> /var/run/netns/hs-t${tid}-${hs}
# using the alias should work
ip -n hs-t${tid}-${hs} link
#delete the alias at exit time
rm -f /var/run/netns/hs-t${tid}-${hs}
The troublesome part is that the '/var/run/netns/' prefix could be
configured to something else at iproute build time.
@David, @Stephen: I'm wondering if it would make sense adding a new
'ip netns' sub-command to implement the 'alias' feature above?
Cheers,
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Discuss] Seeking advice on net selftests netns naming method
2023-11-15 9:10 ` Paolo Abeni
@ 2023-11-15 9:35 ` Hangbin Liu
0 siblings, 0 replies; 5+ messages in thread
From: Hangbin Liu @ 2023-11-15 9:35 UTC (permalink / raw)
To: Paolo Abeni
Cc: David Ahern, Stephen Hemminger, netdev, David S. Miller,
Jakub Kicinski, Eric Dumazet, Shuah Khan, linux-kselftest,
Po-Hsu Lin, Guillaume Nault
On Wed, Nov 15, 2023 at 10:10:38AM +0100, Paolo Abeni wrote:
> > Thanks, this is a good idea. I reviewed all the test cases and it should works
> > for most of them. Only the SRv6 tests are a little complex as they use 2 id
> > number for netns name. e.g. the setup_hs() in
> > srv6_end_dt46_l3vpn_test.sh. I plan to add the tmp string between the hs/rt and
> > ids. e.g. hs-xxxxxx-t100-1, rt-xxxxxx-1. I will have a try first.
>
> Supposing netns_init() creates a namespace named <unique>, I think the
> following (very hackish thing) would work:
>
> # create an alias for the namespace
> ln -s /var/run/netns/<unique> /var/run/netns/hs-t${tid}-${hs}
We can't do this as the purpose of using "unique" namespace name is do
Parallel testing. If we create the soft link and run multi SRv6 tests (there
are multi SRv6 tests with same netns name) at the same time, the naming will
be conflict.
Thanks
Hangbin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-15 9:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-14 9:55 [Discuss] Seeking advice on net selftests netns naming method Hangbin Liu
2023-11-14 11:02 ` Paolo Abeni
2023-11-15 7:51 ` Hangbin Liu
2023-11-15 9:10 ` Paolo Abeni
2023-11-15 9:35 ` Hangbin Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox