opentechinstitute / luci-commotion

Commotion configuration pages for the LuCI web interface
GNU General Public License v3.0
11 stars 17 forks source link

MAC address incorrect in luci advanced menus (1.2rc1) #467

Open andygunn opened 9 years ago

andygunn commented 9 years ago

In Advanced -> Network -> Interfaces, the MAC address for the mesh interface (wlan0) shows up as 00:00:00:00:00:00, rather than the proper MAC address (which can be seen when running the ifconfig command from the command line).

First noticed by Protagonistics, relayed in IRC.

seamustuohy commented 9 years ago

If you have a router handy, can you tell me the section name? I am eating lunch right now and can see if I can find something. This also, as an advanced menu item, might be an upstream bug we want to file if we can isolate the problem.

andygunn commented 9 years ago

Not sure what you mean by section name, but a screenshot is here: mac address error

Agreed it might be upstream, but not sure.

jheretic commented 9 years ago

@andygunn section name is the name is the name of the config section in a UCI file, i.e. in /etc/config/network particular interfaces would be defined as:

config '' ''

Where '' is what (I believe) @elationfoundation is talking about, unless it's an anonymous section.

andygunn commented 9 years ago

Ah, ok.

root@CassCo-3rdStreet-NanoLocoM5:/etc/config# cat network 

config interface 'loopback'
    option ifname 'lo'
    option proto 'static'
    option ipaddr '127.0.0.1'
    option netmask '255.0.0.0'

config interface 'lan'
    option proto 'commotion'
    option class 'client'
    option type 'bridge'
    option bridge_empty '1'

config interface 'wan'
    option ifname 'eth0'
    option proto 'commotion'
    option class 'wired'
    option dhcp 'none'
    option ipaddr '192.168.101.5'
    option netmask '255.255.255.0'
    option meshed '1'

config interface 'thisnode'
    option ifname 'br-lan'
    option proto 'static'
    option ipaddr '169.254.140.121'
    option netmask '255.255.0.0'

config interface 'testbed5'
    option class 'mesh'
    option proto 'commotion'
    option profile 'testbed5'
seamustuohy commented 9 years ago

Thanks Andy!

Here is the code you are looking for:

function interface.mac(self)
    return (self:_ubus("macaddr") or "00:00:00:00:00:00"):upper()
end

And, here is that Ubus code that is returning None, causing the "00:00:00:00:00:00" to be returned

function interface._ubus(self, field)
    if not _ubusdevcache[self.ifname] then
        _ubusdevcache[self.ifname] = utl.ubus("network.device", "status",
                                                                     { name = self.ifname })
    end
    if _ubusdevcache[self.ifname] and field then
        return _ubusdevcache[self.ifname][field]
    end
    return _ubusdevcache[self.ifname]
end

That should help you guys explore the issue. Don't have a Commotion router to do any exploration on.