Re: [PATCH net-next v2 8/8] selftests: net: Add two test cases for link netns

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

 



On Sun, Nov 10, 2024 at 9:01 AM Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
>
> On Thu,  7 Nov 2024 21:30:03 +0800 Xiao Liang wrote:
> > +class NSEnter:
> > +    def __init__(self, ns_name):
> > +        self.ns_path = f"/run/netns/{ns_name}"
> > +
> > +    def __enter__(self):
> > +        self.saved = open("/proc/thread-self/ns/net")
> > +        with open(self.ns_path) as ns_file:
> > +            libc.setns(ns_file.fileno(), 0)
> > +
> > +    def __exit__(self, exc_type, exc_value, traceback):
> > +        libc.setns(self.saved.fileno(), 0)
> > +        self.saved.close()
>
> This is quite nice, why not move it to
> tools/testing/selftests/net/lib/py/netns.py
> so others can use it too

Sure, I will move it to lib.





[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