Re: [PATCHv2 net-next 01/14] selftests/net: add lib.sh

Hangbin Liu
2023-12-01T06:20:57Z

On Fri, Dec 01, 2023 at 01:56:51PM +0800, Po-Hsu Lin wrote:
> > +# setup netns with given names as prefix. e.g
> > +# setup_ns local remote
> > +setup_ns()
> > +{
> > + local ns=""
> > + local ns_name=""
> > + local ns_list=""
> > + for ns_name in "$@"; do
> > + # Some test may setup/remove same netns multi times
> > + if unset ${ns_name} 2> /dev/null; then
> > + ns="${ns_name,,}-$(mktemp -u XXXXXX)"
> > + eval readonly ${ns_name}="$ns"
> > + else
> > + eval ns='$'${ns_name}
> > + cleanup_ns "$ns"
> > +
> > + fi
> > +
> > + if ! ip netns add "$ns"; then
> > + echo "Failed to create namespace $ns_name"
> > + cleanup_ns "$ns_list"
> > + return $ksft_skip
> > + fi
> > + ip -n "$ns" link set lo up
> I got this patchset tested the result is looking good. However it
> seems that not all of the tests require this loopback bring up, e.g.
> * arp_ndisc_untracked_subnets.sh
> * cmsg_ipv6.sh
> * cmsg_so_mark.sh
> * cmsg_time.sh
> * drop_monitor_tests.sh
> * icmp.sh
> * ndisc_unsolicited_na_test.sh
> * sctp_vrf.sh
> * unicast_extensions.sh
>
> A possible solution could be adding an extra flag to setup_ns(), bring
> lo up on demand.
>
> Not sure if this is needed, as I can't think of possible impacts of
> this for the moment.
> (Maybe a test does not require loopback device in such state?)
> Other might be able to provide some feedback about this.

Yes, I also can't think of impact of set lo up. So I just do it explicit.
If someone could help find out the impact, I can add a flag for this function.

Thanks
Hangbin