From 5ec08d841d778c1bb60fe34f8b0ab5fc9c086e11 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 6 May 2020 23:55:42 +0200 Subject: [PATCH 1/5] gluon-core: platform: clean up device_supports_mfp() - Use util.find_phy() - Stop foreach() as soon as the result is known --- package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua index 47138958..8ffcd1cd 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua @@ -66,21 +66,20 @@ function M.device_supports_wpa3() end function M.device_supports_mfp(uci) - local idx = 0 local supports_mfp = true if not M.device_supports_wpa3() then return false end - uci:foreach('wireless', 'wifi-device', function() - local phypath = '/sys/kernel/debug/ieee80211/phy' .. idx .. '/' + uci:foreach('wireless', 'wifi-device', function(radio) + local phy = util.find_phy(radio) + local phypath = '/sys/kernel/debug/ieee80211/' .. phy .. '/' if not util.file_contains_line(phypath .. 'hwflags', 'MFP_CAPABLE') then supports_mfp = false + return false end - - idx = idx + 1 end) return supports_mfp From f4fe58cfd7eaaeab11a7eea89e9faeffd1e7c353 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 7 May 2020 00:19:33 +0200 Subject: [PATCH 2/5] gluon-core: ignore is_outdoor_device() value on devices without 5GHz radio --- .../lib/gluon/config-mode/wizard/0250-outdoor.lua | 2 +- .../luasrc/lib/gluon/upgrade/180-outdoors | 2 +- .../luasrc/usr/lib/lua/gluon/platform.lua | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua b/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua index a4753f5a..c36c1f8f 100644 --- a/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua +++ b/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua @@ -1,7 +1,7 @@ return function(form, uci) local platform = require 'gluon.platform' - if not platform.is_outdoor_device() then + if not (platform.is_outdoor_device() and platform.device_uses_11a(uci)) then -- only visible on wizard for outdoor devices return end diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/180-outdoors b/package/gluon-core/luasrc/lib/gluon/upgrade/180-outdoors index f9278e1f..5c5a92e2 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/180-outdoors +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/180-outdoors @@ -22,7 +22,7 @@ if sysconfig.gluon_version then outdoor = false elseif config == 'preset' then -- enable outdoor mode through presets on new installs - outdoor = platform.is_outdoor_device() + outdoor = platform.is_outdoor_device() and platform.device_uses_11a(uci) else -- enable/disable outdoor mode unconditionally on new installs outdoor = config diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua index 8ffcd1cd..1b20d0fd 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua @@ -85,4 +85,17 @@ function M.device_supports_mfp(uci) return supports_mfp end +function M.device_uses_11a(uci) + local ret = false + + uci:foreach('wireless', 'wifi-device', function(radio) + if radio.hwmode == '11a' or radio.hwmode == '11na' then + ret = true + return false + end + end) + + return ret +end + return M From 0dd9a3e07ce2f7e39b647ecb1409d24e2c965d77 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 7 May 2020 00:29:12 +0200 Subject: [PATCH 3/5] gluon-core: platform: add 2.4GHz-only outdoor devices --- package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua index 1b20d0fd..85f1de76 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua @@ -26,7 +26,10 @@ end function M.is_outdoor_device() if M.match('ar71xx', 'generic', { 'bullet-m', + 'cpe210', 'cpe510', + 'wbs210', + 'wbs510', 'lbe-m5', 'loco-m-xw', 'nanostation-m', @@ -35,6 +38,7 @@ function M.is_outdoor_device() 'rocket-m-ti', 'rocket-m-xw', 'unifi-outdoor', + 'unifi-outdoor-plus', }) then return true @@ -46,7 +50,10 @@ function M.is_outdoor_device() M.get_model() == 'Ubiquiti UniFi-AC-MESH-PRO' then return true - elseif M.match('ath79', 'generic', {'devolo,dvl1750x'}) then + elseif M.match('ath79', 'generic', { + 'devolo,dvl1750x', + 'tplink,cpe220-v3', + }) then return true elseif M.match('ipq40xx', 'generic', {'engenius,ens620ext'}) then From e9687d7ef1bac7fec410b276a20465344150facf Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 7 May 2020 00:33:36 +0200 Subject: [PATCH 4/5] gluon-setup-mode: use is_outdoor_device() for setup_ifname selection On PoE-powered devices, we usually want to use WAN for the setup mode. As all outdoor devices are PoE-powered, we can reuse this function. This switches the setup mode interface for new installations / after config reset on a few devices that were missing in this list before. --- .../luasrc/lib/gluon/upgrade/320-setup-ifname | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/320-setup-ifname b/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/320-setup-ifname index 7f0ca7b8..c4ef517c 100755 --- a/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/320-setup-ifname +++ b/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/320-setup-ifname @@ -8,18 +8,14 @@ if sysconfig.setup_ifname then os.exit(0) end -if platform.match('ar71xx', 'generic', { - 'cpe210', - 'cpe510', - 'wbs210', - 'wbs510', - 'airgateway', - 'nanostation-m', - 'nanostation-m-xw', - 'unifi-outdoor-plus', - 'uap-pro', - 'unifiac-pro' -}) or platform.match('ar71xx', 'mikrotik') then +if platform.is_outdoor_device() or + platform.match('ar71xx', 'generic', { + 'airgateway', + 'uap-pro', + 'unifiac-pro' + }) or + platform.match('ar71xx', 'mikrotik') +then sysconfig.setup_ifname = sysconfig.config_ifname or sysconfig.wan_ifname or sysconfig.lan_ifname else sysconfig.setup_ifname = sysconfig.config_ifname or sysconfig.lan_ifname or sysconfig.wan_ifname From 8807c76a34b25db0f322c980fcbe42ef7304fdf3 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 7 May 2020 00:35:45 +0200 Subject: [PATCH 5/5] gluon-setup-mode: remove obsolete sysconfig.config_ifname migration config_ifname was renamed to setup_ifname in Gluon v2015.1. --- .../luasrc/lib/gluon/upgrade/320-setup-ifname | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/320-setup-ifname b/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/320-setup-ifname index c4ef517c..b1c87623 100755 --- a/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/320-setup-ifname +++ b/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/320-setup-ifname @@ -16,10 +16,7 @@ if platform.is_outdoor_device() or }) or platform.match('ar71xx', 'mikrotik') then - sysconfig.setup_ifname = sysconfig.config_ifname or sysconfig.wan_ifname or sysconfig.lan_ifname + sysconfig.setup_ifname = sysconfig.wan_ifname or sysconfig.lan_ifname else - sysconfig.setup_ifname = sysconfig.config_ifname or sysconfig.lan_ifname or sysconfig.wan_ifname + sysconfig.setup_ifname = sysconfig.lan_ifname or sysconfig.wan_ifname end - --- Remove the old sysconfig setting -sysconfig.config_ifname = nil