gluon-core: primary-mac: add fallback to netdev address to interface()
In most cases, board.json does not contain any MAC addresses; in this case, the default MAC address of the underlying interface is to be used.
This commit is contained in:
parent
2250665d18
commit
02e4a13069
@ -26,6 +26,10 @@ local function get_netdev_addr(ifname)
|
||||
return read('/sys/class/net/%s/address', ifname)
|
||||
end
|
||||
|
||||
local function strip_vlan(ifname)
|
||||
return (ifname:gsub('%..*', ''))
|
||||
end
|
||||
|
||||
|
||||
local function netdev(ifname)
|
||||
return function()
|
||||
@ -44,6 +48,8 @@ local function interface(name)
|
||||
local ifdata = network_data[name] or {}
|
||||
if ifdata.macaddr then
|
||||
return ifdata.macaddr
|
||||
elseif ifdata.ifname then
|
||||
return get_netdev_addr(strip_vlan(ifdata.ifname))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user