From fd3ecea95304444c2722b029f29b30d133b9d416 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Sun, 10 Jan 2021 00:51:15 +0100 Subject: [PATCH] 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 --- package/gluon-core/files/lib/gluon/label_mac.sh | 5 +++++ .../luasrc/lib/gluon/upgrade/010-primary-mac | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100755 package/gluon-core/files/lib/gluon/label_mac.sh diff --git a/package/gluon-core/files/lib/gluon/label_mac.sh b/package/gluon-core/files/lib/gluon/label_mac.sh new file mode 100755 index 00000000..3479324b --- /dev/null +++ b/package/gluon-core/files/lib/gluon/label_mac.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +. /lib/functions/system.sh + +get_mac_label diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/010-primary-mac b/package/gluon-core/luasrc/lib/gluon/upgrade/010-primary-mac index 18694936..f4cbfdab 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/010-primary-mac +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/010-primary-mac @@ -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