Skip to content
Snippets Groups Projects
Unverified Commit 02e4a130 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

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.
parent 2250665d
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,10 @@ local function get_netdev_addr(ifname) ...@@ -26,6 +26,10 @@ local function get_netdev_addr(ifname)
return read('/sys/class/net/%s/address', ifname) return read('/sys/class/net/%s/address', ifname)
end end
local function strip_vlan(ifname)
return (ifname:gsub('%..*', ''))
end
local function netdev(ifname) local function netdev(ifname)
return function() return function()
...@@ -44,6 +48,8 @@ local function interface(name) ...@@ -44,6 +48,8 @@ local function interface(name)
local ifdata = network_data[name] or {} local ifdata = network_data[name] or {}
if ifdata.macaddr then if ifdata.macaddr then
return ifdata.macaddr return ifdata.macaddr
elseif ifdata.ifname then
return get_netdev_addr(strip_vlan(ifdata.ifname))
end end
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment