From d36271be82a162431df0c00d04d9a87a1e96fd12 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Wed, 15 Mar 2023 05:29:19 +0100 Subject: [PATCH] gluon-core: set WAN mac from board-data Set the MAC-adress for the WAN interfacce in case it is defined in the board-data. This commit fixes random MAC-Addresses on reboot in case OpenWrt stores them in the device network configuration. Fixes #2808 Signed-off-by: David Bauer --- .../luasrc/lib/gluon/upgrade/110-network | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/110-network b/package/gluon-core/luasrc/lib/gluon/upgrade/110-network index be82ec5c..d1493d26 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/110-network +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/110-network @@ -4,6 +4,19 @@ local uci = require('simple-uci').cursor() local sysconfig = require 'gluon.sysconfig' local util = require 'gluon.util' +local json = require 'jsonc' + +local function get_network_mac(name) + local board_data = json.load('/etc/board.json') + local network_data = (board_data or {}).network + + if network_data == nil then + return nil + end + + local ifdata = network_data[name] or {} + return ifdata.macaddr +end local wan = uci:get_all('network_gluon-old', 'wan') or {} local wan6 = uci:get_all('network_gluon-old', 'wan6') or {} @@ -27,6 +40,7 @@ uci:section('network', 'interface', 'wan', { ipaddr = wan.ipaddr, netmask = wan.netmask, gateway = wan.gateway, + macaddr = get_network_mac('wan'), ifname = util.get_role_interfaces(uci, 'uplink'), type = 'bridge', igmp_snooping = true,