From: James Prestwood <prestwoj@gmail.com>
To: Andrew Zaborowski <andrew.zaborowski@intel.com>
Cc: iwd@lists.linux.dev
Subject: Re: [PATCH v2 1/4] test-runner: Support running hostapd in namespaces
Date: Thu, 07 Jul 2022 16:19:25 -0700 [thread overview]
Message-ID: <fc33625c8f1531df696fbc07099f16e71f7b4a86.camel@gmail.com> (raw)
In-Reply-To: <CAOq732KGfw5_JkjDh09W0Jp6CfcECLweifFCEY1iCAXZ6kX+Lw@mail.gmail.com>
Hi Andrew,
> > > class Radio:
> > > def __init__(self, name):
> > > @@ -75,11 +78,16 @@ class Radio:
> > > # hostapd will reset this if this radio is used
> > > by it
> > > self.use = 'iwd'
> > > self.interface = None
> > > + self.ns = None
> > >
> > > def __del__(self):
> > > print("Removing radio %s" % self.name)
> > > self.interface = None
> > >
> > > + def set_namespace(self, ns):
> > > + self.ns = ns
> > > + Process(['iw', 'phy', self.name, 'set', 'netns',
> > > 'name', ns.name]).wait()
> > > +
> > > def create_interface(self, config, use):
> > > global intf_id
> > >
> > > @@ -87,19 +95,21 @@ class Radio:
> > >
> > > intf_id += 1
> > >
> > > - self.interface = Interface(ifname, config)
> > > + self.interface = Interface(ifname, config,
> > > ns=self.ns)
> > > self.use = use
> > >
> > > Process(['iw', 'phy', self.name, 'interface',
> > > 'add',
> > > ifname,
> > > - 'type', 'managed']).wait()
> > > + 'type', 'managed'],
> > > namespace=self.ns.name if self.ns else None).wait()
> > >
> > > return self.interface
> >
> > Since create_interface() is the only function that needs the
> > namespace
> > couldn't we remove set_namespace entirely and just pass the
> > namespace
> > name into create_interface?
>
> So set_namespace() also moves the radio to the right namespace. We
> need this for radios used by both hostapd and IWD, where we don't use
> create_interface().
>
> I also think it's nice if you can obtain the namespace reference from
> `radio.ns` or `interface.ns`, say, in autotests/util/*.py code or
> elsewhere.
Are there situations where hostapd and IWD share a radio?
But I agree, its nice knowing what namespace a radio/interface belongs
to.
>
> >
> > > + def get_hapd_instance(self, config=None):
> > > + instances = [i for hapd in self.hostapd for i in
> > > hapd.instances]
> > > +
> > > + if config is None:
> > > + return instances[0]
> > > +
> > > + for hapd in instances:
> > > + if hapd.config == config:
> > > + return hapd
> > > +
> >
> > Looks like this got carried over from that dropped patch?
>
> I use this in autotests/util/hostapd.py (patch 2/4) since ctx.hostapd
> is now a list and to override the [] operator you'd need to subclass
> the list and overall it's simpler this way.
Sorry, I was confusing this with the HostapdCLI stuff. Nevermind.
>
> Thanks for the review,
> Best regards
next prev parent reply other threads:[~2022-07-07 23:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-07 20:03 [PATCH v2 1/4] test-runner: Support running hostapd in namespaces Andrew Zaborowski
2022-07-07 20:03 ` [PATCH v2 2/4] autotests: DHCPv4 renewal/resend test in testNetconfig Andrew Zaborowski
2022-07-07 20:03 ` [PATCH v2 3/4] autotests: Also validate correct hostname sent over DHCPv4 Andrew Zaborowski
2022-07-07 20:03 ` [PATCH v2 4/4] test-runner: Mark source directory as safe for git Andrew Zaborowski
2022-07-07 22:37 ` [PATCH v2 1/4] test-runner: Support running hostapd in namespaces James Prestwood
2022-07-07 23:11 ` Andrew Zaborowski
2022-07-07 23:19 ` James Prestwood [this message]
2022-07-07 23:42 ` Andrew Zaborowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fc33625c8f1531df696fbc07099f16e71f7b4a86.camel@gmail.com \
--to=prestwoj@gmail.com \
--cc=andrew.zaborowski@intel.com \
--cc=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).