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.
This commit is contained in:
Matthias Schiffer 2018-01-10 01:00:28 +01:00
parent 0b6f433478
commit 18b9174d03
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
5 changed files with 33 additions and 23 deletions

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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)
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 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
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')

View File

@ -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")