Browse Source

Use 'disabled' attribute instead of 'auto' to disable wired mesh interfaces

The 'auto' attribute still allows enabling the interface using ifup, which
is not intended when wired mesh is disabled.
Matthias Schiffer 6 years ago
parent
commit
18b9174d03

+ 4 - 4
docs/features/wired-mesh.rst

@@ -32,12 +32,12 @@ Mesh-on-WAN
 
 It's possible to enable Mesh-on-WAN like this::
 
-  uci set network.mesh_wan.auto=1
+  uci set network.mesh_wan.disabled=0
   uci commit network
 
 It may be disabled by running::
 
-  uci set network.mesh_wan.auto=0
+  uci set network.mesh_wan.disabled=1
   uci commit network
 
 
@@ -46,7 +46,7 @@ Mesh-on-LAN
 
 Configuring Mesh-on-LAN is a bit more complicated::
 
-  uci set network.mesh_lan.auto=1
+  uci set network.mesh_lan.disabled=0
   for ifname in $(cat /lib/gluon/core/sysconfig/lan_ifname); do
     uci del_list network.client.ifname=$ifname
   done
@@ -54,7 +54,7 @@ Configuring Mesh-on-LAN is a bit more complicated::
 
 It may be disabled by running::
 
-  uci set network.mesh_lan.auto=0
+  uci set network.mesh_lan.disabled=1
   for ifname in $(cat /lib/gluon/core/sysconfig/lan_ifname); do
     uci add_list network.client.ifname=$ifname
   done

+ 1 - 1
package/gluon-client-bridge/luasrc/lib/gluon/upgrade/300-gluon-client-bridge-network

@@ -17,7 +17,7 @@ if type(interfaces) == 'string' then
 	end
 end
 
-if sysconfig.lan_ifname and not ifname and not uci:get_bool('network', 'mesh_lan', 'auto') then
+if sysconfig.lan_ifname and uci:get_bool('network', 'mesh_lan', 'disabled') then
 	for lanif in sysconfig.lan_ifname:gmatch('%S+') do
 		util.add_to_set(interfaces, lanif)
 	end

+ 8 - 2
package/gluon-core/luasrc/lib/gluon/upgrade/210-interface-wan

@@ -11,9 +11,14 @@ uci:section('network', 'interface', 'mesh_wan', {
 	index  = 0,
 })
 
-if uci:get('network', 'mesh_wan', 'auto') == nil then
-	uci:set('network', 'mesh_wan', 'auto', site.mesh_on_wan(false))
+local enable = site.mesh_on_wan(false)
+local old_auto = uci:get('network', 'mesh_wan', 'auto')
+local old_disabled = uci:get('network', 'mesh_wan', 'disabled')
+if old_auto ~= nil or old_disabled ~= nil then
+	enable = old_auto ~= '0' and old_disabled ~= '1'
 end
+uci:set('network', 'mesh_wan', 'disabled', not enable)
+
 if uci:get('network', 'mesh_wan', 'transitive') == nil then
 	uci:set('network', 'mesh_wan', 'transitive', true)
 end
@@ -21,6 +26,7 @@ if uci:get('network', 'mesh_wan', 'legacy') == nil then
 	uci:set('network', 'mesh_wan', 'legacy', old_proto == 'gluon_mesh')
 end
 
+uci:delete('network', 'mesh_wan', 'auto')
 uci:delete('network', 'mesh_wan', 'fixed_mtu')
 
 uci:save('network')

+ 18 - 14
package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan

@@ -21,25 +21,28 @@ uci:section('network', 'interface', 'mesh_lan', {
 	legacy        = old_proto == 'gluon_mesh',
 })
 
-if uci:get('network', 'mesh_lan', 'auto') == nil then
-	local enable = site.mesh_on_lan(false)
-
-	if enable then
-		local interfaces = uci:get_list('network', 'client', 'ifname')
-
-		if interfaces then
-			for lanif in sysconfig.lan_ifname:gmatch('%S+') do
-				if util.contains(interfaces, lanif) then
-					enable = false
-					break
-				end
+local enable = site.mesh_on_lan(false)
+local old_auto = uci:get('network', 'mesh_lan', 'auto')
+local old_disabled = uci:get('network', 'mesh_lan', 'disabled')
+if old_auto ~= nil or old_disabled ~= nil then
+	enable = old_auto ~= '0' and old_disabled ~= '1'
+end
+
+if enable then
+	local interfaces = uci:get_list('network', 'client', 'ifname')
+
+	if interfaces then
+		for lanif in sysconfig.lan_ifname:gmatch('%S+') do
+			if util.contains(interfaces, lanif) then
+				enable = false
+				break
 			end
 		end
 	end
-
-	uci:set('network', 'mesh_lan', 'auto', enable)
 end
 
+uci:set('network', 'mesh_lan', 'disabled', not enable)
+
 if uci:get('network', 'mesh_lan', 'transitive') == nil then
 	uci:set('network', 'mesh_lan', 'transitive', true)
 end
@@ -47,6 +50,7 @@ if uci:get('network', 'mesh_lan', 'legacy') == nil then
 	uci:set('network', 'mesh_lan', 'legacy', old_proto == 'gluon_mesh')
 end
 
+uci:delete('network', 'mesh_lan', 'auto')
 uci:delete('network', 'mesh_lan', 'fixed_mtu')
 
 uci:save('network')

+ 4 - 4
package/gluon-web-network/luasrc/lib/gluon/web/model/admin/network.lua

@@ -77,10 +77,10 @@ end
 local s = f:section(Section)
 
 local mesh_wan = s:option(Flag, "mesh_wan", translate("Enable meshing on the WAN interface"))
-mesh_wan.default = uci:get_bool("network", "mesh_wan", "auto")
+mesh_wan.default = not uci:get_bool("network", "mesh_wan", "disabled")
 
 function mesh_wan:write(data)
-	uci:set("network", "mesh_wan", "auto", data)
+	uci:set("network", "mesh_wan", "disabled", not data)
 end
 
 local mesh_wan_legacy = s:option(Flag, "mesh_wan_legacy", translate("Use legacy mode for WAN meshing"))
@@ -95,10 +95,10 @@ if sysconfig.lan_ifname then
 	local s = f:section(Section)
 
 	local mesh_lan = s:option(Flag, "mesh_lan", translate("Enable meshing on the LAN interface"))
-	mesh_lan.default = uci:get_bool("network", "mesh_lan", "auto")
+	mesh_lan.default = not uci:get_bool("network", "mesh_lan", "disabled")
 
 	function mesh_lan:write(data)
-		uci:set("network", "mesh_lan", "auto", data)
+		uci:set("network", "mesh_lan", "disabled", not data)
 
 		local interfaces = uci:get_list("network", "client", "ifname")