Re: [PATCH net-next 01/38] selftests/net: add lib.sh

2023-11-27 Thread Petr Machata
Hangbin Liu writes: > On Fri, Nov 24, 2023 at 03:35:51PM +0100, Petr Machata wrote: >> >> Hangbin Liu writes: >> >> > + fi >> > + done >> > + >> > + [ $errexit -eq 1 ] && set -e >> > + return 0 >> > +} >> > + >> > +# By default, remove all netns before EXIT. >> >

Re: [PATCH net-next 01/38] selftests/net: add lib.sh

2023-11-27 Thread Petr Machata
Hangbin Liu writes: > On Fri, Nov 24, 2023 at 03:05:18PM +0100, Petr Machata wrote: >> >> Hangbin Liu writes: >> >> > +# Helpers >> > +busywait() >> > +{ >> > + local timeout=$1; shift >> > + >> > + local start_time="$(date -u +%s%3N)" >> > + while true >> > + do >> > + local

Re: [PATCH net-next 01/38] selftests/net: add lib.sh

2023-11-24 Thread Hangbin Liu
On Fri, Nov 24, 2023 at 03:35:51PM +0100, Petr Machata wrote: > > Hangbin Liu writes: > > > +cleanup_ns() > > +{ > > + local ns="" > > + local errexit=0 > > + > > + # disable errexit temporary > > + if [[ $- =~ "e" ]]; then > > + errexit=1 > > + set +e > > + fi > >

Re: [PATCH net-next 01/38] selftests/net: add lib.sh

2023-11-24 Thread Hangbin Liu
On Fri, Nov 24, 2023 at 03:05:18PM +0100, Petr Machata wrote: > > Hangbin Liu writes: > > > Add a lib.sh for net selftests. This file can be used to define commonly > > used variables and functions. > > > > Add function setup_ns() for user to create unique namespaces with given > > prefix name.

Re: [PATCH net-next 01/38] selftests/net: add lib.sh

2023-11-24 Thread Petr Machata
Petr Machata writes: > Hangbin Liu writes: > >> +# By default, remove all netns before EXIT. >> +cleanup_all_ns() >> +{ >> +cleanup_ns $NS_LIST >> +} >> +trap cleanup_all_ns EXIT > > Hmm, OK, this is a showstopper for inclusion from forwarding/lib.sh, > because basically all users of

Re: [PATCH net-next 01/38] selftests/net: add lib.sh

2023-11-24 Thread Petr Machata
Hangbin Liu writes: > +cleanup_ns() > +{ > + local ns="" > + local errexit=0 > + > + # disable errexit temporary > + if [[ $- =~ "e" ]]; then > + errexit=1 > + set +e > + fi > + > + for ns in "$@"; do > + ip netns delete "${ns}" &>

Re: [PATCH net-next 01/38] selftests/net: add lib.sh

2023-11-24 Thread Petr Machata
Hangbin Liu writes: > Add a lib.sh for net selftests. This file can be used to define commonly > used variables and functions. > > Add function setup_ns() for user to create unique namespaces with given > prefix name. > > Signed-off-by: Hangbin Liu > --- >

[PATCH net-next 01/38] selftests/net: add lib.sh

2023-11-24 Thread Hangbin Liu
Add a lib.sh for net selftests. This file can be used to define commonly used variables and functions. Add function setup_ns() for user to create unique namespaces with given prefix name. Signed-off-by: Hangbin Liu --- tools/testing/selftests/net/Makefile | 2 +-