modules/admin-full: only allow unique vlan ids, fix port labelling if CPU is at 0
This commit is contained in:
parent
9e2e9a2b66
commit
760dcec667
1 changed files with 21 additions and 6 deletions
|
@ -205,6 +205,7 @@ m.uci:foreach("network", "switch",
|
||||||
|
|
||||||
vid.rmempty = false
|
vid.rmempty = false
|
||||||
vid.forcewrite = true
|
vid.forcewrite = true
|
||||||
|
vid.vlan_used = { }
|
||||||
|
|
||||||
-- Validate user provided VLAN ID, make sure its within the bounds
|
-- Validate user provided VLAN ID, make sure its within the bounds
|
||||||
-- allowed by the switch.
|
-- allowed by the switch.
|
||||||
|
@ -212,7 +213,13 @@ m.uci:foreach("network", "switch",
|
||||||
local v = tonumber(value)
|
local v = tonumber(value)
|
||||||
local m = has_vlan4k and 4094 or (num_vlans - 1)
|
local m = has_vlan4k and 4094 or (num_vlans - 1)
|
||||||
if v ~= nil and v >= min_vid and v <= m then
|
if v ~= nil and v >= min_vid and v <= m then
|
||||||
return value
|
if not self.vlan_used[v] then
|
||||||
|
self.vlan_used[v] = true
|
||||||
|
return value
|
||||||
|
else
|
||||||
|
return nil,
|
||||||
|
translatef("Invalid VLAN ID given! Only unique IDs are allowed")
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return nil,
|
return nil,
|
||||||
translatef("Invalid VLAN ID given! Only IDs between %d and %d are allowed.", min_vid, m)
|
translatef("Invalid VLAN ID given! Only IDs between %d and %d are allowed.", min_vid, m)
|
||||||
|
@ -246,13 +253,21 @@ m.uci:foreach("network", "switch",
|
||||||
|
|
||||||
-- Build per-port off/untagged/tagged choice lists.
|
-- Build per-port off/untagged/tagged choice lists.
|
||||||
local pt
|
local pt
|
||||||
|
local off = 1
|
||||||
for pt = 0, num_ports - 1 do
|
for pt = 0, num_ports - 1 do
|
||||||
local po = s:option(ListValue, tostring(pt),
|
local title
|
||||||
(pt == cpu_port) and translate("CPU") or translatef("Port %d", (pt + 1)))
|
if pt == cpu_port then
|
||||||
|
off = 0
|
||||||
|
title = translate("CPU")
|
||||||
|
else
|
||||||
|
title = translatef("Port %d", pt + off)
|
||||||
|
end
|
||||||
|
|
||||||
po:value("", translate("off"))
|
local po = s:option(ListValue, tostring(pt), title)
|
||||||
po:value("u" % pt, translate("untagged"))
|
|
||||||
po:value("t" % pt, translate("tagged"))
|
po:value("", translate("off"))
|
||||||
|
po:value("u", translate("untagged"))
|
||||||
|
po:value("t", translate("tagged"))
|
||||||
|
|
||||||
po.cfgvalue = portvalue
|
po.cfgvalue = portvalue
|
||||||
po.validate = portvalidate
|
po.validate = portvalidate
|
||||||
|
|
Loading…
Reference in a new issue