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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2023-12-06 at 13:32 +0100, Petr Machata wrote:
> Paolo Abeni <pabeni@xxxxxxxxxx> writes:
> 
> > Side note for a possible follow-up: if you maintain $ns_list as global
> > variable, and remove from such list the ns deleted by cleanup_ns, you
> > could remove the cleanup trap from the individual test with something
> > alike:
> > 
> > final_cleanup_ns()
> > {
> > 	cleanup_ns $ns_list
> > }
> > 
> > trap final_cleanup_ns EXIT
> > 
> > No respin needed for the above, could be a follow-up if agreed upon.
> 
> If you propose this for the library then I'm against it. The exit trap
> is a global resource that the client scripts sometimes need to use as
> well, to do topology teardowns or just general cleanups. 
> So either the library would have to provide APIs for cleanup management, or the trap
> is for exclusive use by clients. The latter is IMHO simpler.

Even the former would not be very complex:

TRAPS=""
do_at_exit() {
        TRAPS="${TRAPS}$@;"

        trap "${TRAPS}" EXIT
}

And then use "do_at_exit <whatever>" instead of "trap <whatever> EXIT"

> It also puts the cleanups at the same place where the acquisition is
> prompted: the client allocates the NS, the client should prompt its
> cleanup.

I guess I could argue that the the script is asking the library to
allocate the namespaces, and the library could take care of disposing
them.

But I'm not pushing the proposed option, if there is no agreement no
need for additional work ;)

Cheers,

Paolo






[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux