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) uci:set("network", "mesh_lan", "auto", data.mesh_lan)
if data.mesh_lan == '1' then if data.mesh_lan == '1' then
uci:set("network", "client", "ifname", "bat0") uci:remove_from_set("network", "client", "ifname", sysconfig.lan_ifname)
else else
uci:set("network", "client", "ifname", sysconfig.lan_ifname .. " bat0") uci:add_to_set("network", "client", "ifname", sysconfig.lan_ifname)
end end
end end

View File

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