gluon-core: use OpenWrt label-mac as fallback (#2170)

This adds the OpenWrt label-mac device selection as the most preferred
fallback.

While this is only used on OpenWrt 19.07 for backports, we can also use
the label-mac device when backporting device support. This way, we have
to deal with less device-sepcific code downstream.

Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
David Bauer 2021-01-10 00:51:15 +01:00 committed by GitHub
parent 7320603a1f
commit fd3ecea953
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,5 @@
#!/bin/sh
. /lib/functions/system.sh
get_mac_label

View File

@ -54,6 +54,19 @@ local function interface(name)
end
end
local function label_mac()
return function()
local mac = util.exec('/lib/gluon/label_mac.sh')
if mac == nil then return nil end
mac = util.trim(mac)
if string.len(mac) ~= 17 then return nil end
return mac
end
end
-- Entries are matched in the order they are listed
local primary_addrs = {
@ -148,6 +161,10 @@ local primary_addrs = {
'dir-860l-b1',
}},
}},
-- label-mac-device default
{label_mac(), {
{}, -- matches everything
}},
-- phy0 default
{phy(0), {
{}, -- matches everything