From 5e44f7cddeed45566271f69c9f00a5151ca4ebfd Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 14 Jun 2020 12:11:32 +0200 Subject: [PATCH 1/2] gluon-core: get LAN and WAN interfaces from board.json Instead of looking at the initial UCI config, we can read this information from board.json. --- package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces index 1e101f70..d10d3cbe 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces @@ -11,9 +11,12 @@ end local platform = require 'gluon.platform' local site = require 'gluon.site' +local json = require 'jsonc' local uci = require('simple-uci').cursor() local unistd = require 'posix.unistd' +local board_data = json.load('/etc/board.json') +local network_data = (board_data or {}).network local function iface_exists(ifaces) if not ifaces then return nil end @@ -26,8 +29,8 @@ local function iface_exists(ifaces) end -local lan_ifname = iface_exists(uci:get('network', 'lan', 'ifname')) -local wan_ifname = iface_exists(uci:get('network', 'wan', 'ifname')) +local lan_ifname = iface_exists((network_data.lan or {}).ifname) +local wan_ifname = iface_exists((network_data.wan or {}).ifname) if platform.match('ar71xx', 'generic', { 'cpe210', From fa0e2d06b6c1692290f9a2b70ef784f332f8d837 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 14 Jun 2020 12:43:54 +0200 Subject: [PATCH 2/2] gluon-core: lantiq: use WAN interface from switch0 configuration On lantiq, the default WAN ifname is 'dsl0' even on devices that have a separate WAN port. At least on devices using swconfig we can override this with the switch port labelled as 'wan'. --- .../gluon-core/luasrc/lib/gluon/upgrade/020-interfaces | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces index d10d3cbe..5bb1926d 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces @@ -45,6 +45,16 @@ if platform.match('ar71xx', 'generic', { 'unifiac-pro', }) then lan_ifname, wan_ifname = wan_ifname, lan_ifname +elseif platform.match('lantiq') then + local switch_data = board_data.switch or {} + local switch0_data = switch_data.switch0 or {} + local roles_data = switch0_data.roles or {} + for _, role_data in ipairs(roles_data) do + if role_data.role == 'wan' then + wan_ifname = iface_exists(role_data.device) + break + end + end end if wan_ifname and lan_ifname then