From 3c2593b68436479d10cfa09def81b6f8b6e3546b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 11 Jun 2020 23:52:22 +0200 Subject: [PATCH 1/3] gluon-core: fix handling of 'disabled' site.conf attributes for mesh interfaces Because is_disabled() was always returning true or false, the first_non_nil() would never actually check the default setting from site.conf. This was broken since v2017.1. Fixes: 6cf03bab37f9 ("treewide: replace normal uses of luci.model.uci with simple-uci to reduce LuCI dependencies") --- package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless index f72908a2..073d0694 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless @@ -85,7 +85,7 @@ local function is_disabled(name) if uci:get('wireless', name) then return uci:get_bool('wireless', name, 'disabled') else - return false + return nil end end From d2052431dd4ab4c1c5e0ce406219e281df297715 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 12 Jun 2020 00:02:15 +0200 Subject: [PATCH 2/3] gluon-web-wifi-config: default to enabled 5GHz mesh interfaces when disabling outdoor mode When disabling outdoor mode, 5GHz mesh interfaces should be enabled by default again (unless disabled in site.conf). --- .../luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua b/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua index 98501bd8..efc6d0f0 100644 --- a/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua +++ b/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua @@ -1,5 +1,6 @@ local iwinfo = require 'iwinfo' local uci = require("simple-uci").cursor() +local site = require 'gluon.site' local wireless = require 'gluon.wireless' @@ -155,6 +156,9 @@ if has_5ghz_radio() then for _, mesh_vif in ipairs(mesh_vifs_5ghz) do mesh_vif:depends(outdoor, false) + if outdoor.default then + mesh_vif.default = not site.wifi5.mesh.disabled(false) + end end function outdoor:write(data) From 17bc6228929b38356d4209af64f807432daf713b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 12 Jun 2020 00:12:24 +0200 Subject: [PATCH 3/3] gluon-config-mode-outdoor: enable 5GHz mesh interfaces when disabling outdoor mode There is no setting to explicitly enable mesh interfaces in the config wizard, so we need to enable mesh interfaces by default when the outdoor mode is disabled (unless site.conf dictates otherwise). The simplest way to achieve this is to delete the 5GHz mesh interface sections when outdoor mode is disabled: 200-wireless would delete and recreate them a moment later anyways, but by deleting them earlier we ensure that the disabled status is initialized from site.conf again. --- .../gluon/config-mode/wizard/0250-outdoor.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 3f1f0cbe..ffa030dd 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 @@ -21,6 +21,24 @@ return function(form, uci) if data ~= outdoor_mode then uci:set('gluon', 'wireless', 'outdoor', data) uci:save('gluon') + + if data == false then + local mesh_ifaces_5ghz = {} + uci:foreach('wireless', 'wifi-device', function(config) + if config.hwmode ~= '11a' and config.hwmode ~= '11na' then + return + end + + local radio_name = config['.name'] + local mesh_iface = 'mesh_' .. radio_name + table.insert(mesh_ifaces_5ghz, mesh_iface) + end) + for _, mesh_iface in ipairs(mesh_ifaces_5ghz) do + uci:delete('wireless', mesh_iface) + end + uci:save('wireless') + end + os.execute('/lib/gluon/upgrade/200-wireless') end end