lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8093c847a556cf38c40f5e9329b087ea34f59e29.camel@redhat.com>
Date: Wed, 15 Nov 2023 10:10:38 +0100
From: Paolo Abeni <pabeni@...hat.com>
To: Hangbin Liu <liuhangbin@...il.com>, David Ahern <dsahern@...nel.org>, 
	Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>, Jakub
 Kicinski <kuba@...nel.org>, Eric Dumazet <edumazet@...gle.com>, Shuah Khan
 <shuah@...nel.org>,  David Ahern <dsahern@...nel.org>,
 linux-kselftest@...r.kernel.org, Po-Hsu Lin <po-hsu.lin@...onical.com>, 
 Guillaume Nault <gnault@...hat.com>
Subject: Re: [Discuss] Seeking advice on net selftests netns naming method

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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ