br-client: convert option ifname to list ifname

Convert option ifname in br-client to use a list instead. This
simplifies adding and remove interfaces:

uci:add_to_set("network", "client", "ifname", "eth0")
uci:remove_from_set("network", "client", "ifname", "eth0")

An option ifname will be automatically converted to a list when
performing an upgrade.

Packages affected: gluon-mesh-batman-adv-core, gluon-luci-portconfig
This commit is contained in:
Nils Schneider 2015-08-17 21:29:37 +02:00
parent 7c6703d84b
commit 34752c7e0b
3 changed files with 22 additions and 16 deletions

View File

@ -122,9 +122,9 @@ function f.handle(self, state, data)
uci:set("network", "mesh_lan", "auto", data.mesh_lan)
if data.mesh_lan == '1' then
uci:set("network", "client", "ifname", "bat0")
uci:remove_from_set("network", "client", "ifname", sysconfig.lan_ifname)
else
uci:set("network", "client", "ifname", sysconfig.lan_ifname .. " bat0")
uci:add_to_set("network", "client", "ifname", sysconfig.lan_ifname)
end
end

View File

@ -20,22 +20,28 @@ uci:commit('batman-adv')
if not uci:get('network', 'client') then
local ifname
uci:section('network', 'interface', 'client',
{
type = 'bridge',
proto = 'dhcpv6',
reqprefix = 'no',
}
)
uci:add_to_set('network', 'client', 'ifname', 'bat0')
if sysconfig.lan_ifname and not site.mesh_on_lan then
ifname = sysconfig.lan_ifname .. ' bat0'
else
ifname = 'bat0'
uci:add_to_set('network', 'client', 'ifname', sysconfig.lan_ifname)
end
end
uci:section('network', 'interface', 'client',
{
ifname = ifname,
type = 'bridge',
proto = 'dhcpv6',
reqprefix = 'no',
}
)
local ifname = uci:get('network', 'client', 'ifname')
if type(ifname) == 'string' then
uci:delete('network', 'client', 'ifname')
for x in ifname:gmatch("[^%s]+") do
uci:add_to_set('network', 'client', 'ifname', x)
end
end
uci:set('network', 'client', 'igmp_snooping', 0)

View File

@ -11,9 +11,9 @@ if sysconfig.lan_ifname and not uci:get('network', 'mesh_lan') then
local enable = site.mesh_on_lan
if enable then
local interfaces = uci:get('network', 'client', 'ifname')
local interfaces = uci:get_list('network', 'client', 'ifname')
if interfaces and lutil.contains(interfaces:split(' '), sysconfig.lan_ifname) then
if interfaces and lutil.contains(interfaces, sysconfig.lan_ifname) then
enable = false
end
end