Search Linux Wireless

Re: [RFC 0/1] Allow MAC change on up interface

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

 



On Mon, 2019-08-19 at 12:14 +0200, Johannes Berg wrote:
> On Thu, 2019-08-15 at 11:57 -0700, James Prestwood wrote:
> > This is an example of how a devices MAC address could be changed
> > while
> > the interface is up. Currently RTNL and mac80211 both require the
> > interface be down before changing the MAC.
> > 
> > After poking around a bit I found that some drivers can actually
> > change the MAC while the iface is up. Allowing user space to do
> > this
> > while the iface is up would elminate a few potential race
> > conditions
> > that arise when changing the MAC from user space.
> > 
> > This commit does a few things:
> >  - Adds an EXT_FEATURE that user space can check to see if the
> > driver
> >    allows this MAC changing.
> >  - Adds a new NL80211_ATTR for including a "random mac" to     
> >    CMD_CONNECT. This MAC is passed down the stack and gets set to 
> >    the net_device's address.
> >  - Set this wiphy extended feature in iwlwifi (just as an example)
> >  - Relax checks in mac80211 which check if the interface is running
> >  - Set IFF_LIVE_ADDR_CHANGE on net_device. Note: I know setting
> > this
> >    where I did is likely not the right way to do it, but for this
> >    proof-of-concept it works. With guidance I can move this around
> >    to a proper place.
> 
> 
> It actually seems wrong to set IFF_LIVE_ADDR_CHANGE at all, because
> you
> don't actually support that - you only support setting it while not
> connected?

You are right, we only care about setting the MAC while not connected.
But, the eth_ API's that set the MAC are contingent on
IFF_LIVE_ADDR_CHANGE when the interface is running. If you follow down
'dev_set_mac_address':

dev_set_mac_address ->
   ndo_set_mac_address (ieee80211_change_mac) ->
      eth_mac_addr ->
         eth_prepare_mac_addr_change:

You see the check for:

!(dev->priv_flags & IFF_LIVE_ADDR_CHANGE) && netif_running(dev)

Like I said in my commit message, I did not think setting
IFF_LIVE_ADDR_CHANGE where I did was the correct way to do it, but
unless this eth code is changed its looking like it does need to be set
somewhere to change the MAC while 'running'.

Maybe this is a historical thing but the comment about
IFF_LIVE_ADDR_CHANGE says "device supports hardware address change when
it's running". Isn't a wireless adapter 'running' when not connected?
Or does 'running' indicate some different state than up/down?

If you have any suggestions on how I could do this without setting
IFF_LIVE_ADDR_CHANGE I am all ears.

Thanks,
James

> 
> johannes
> 




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux