X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=applications%2Fluci-app-mwan3%2Fluasrc%2Fmodel%2Fcbi%2Fmwan%2Finterface.lua;h=162b388d17e944319e95615fbb3d365412edad8f;hp=14bf1384f78eff1673f07348a2792049794cc4aa;hb=65eacaef1627a365d6242c7b636c1e731c167fbd;hpb=7161284d752cca0d1cc54b68650fd570b6d2da1a
diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua
index 14bf1384f..162b388d1 100644
--- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua
+++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua
@@ -3,17 +3,18 @@
-- Licensed to the public under the GNU General Public License v2.
dsp = require "luci.dispatcher"
+uci = require "uci"
-function interfaceWarnings(overview, count)
+function interfaceWarnings(overview, count, iface_max)
local warnings = ""
- if count <= 250 then
+ if count <= iface_max then
warnings = string.format("%s
",
- translatef("There are currently %d of 250 supported interfaces configured", count)
+ translatef("There are currently %d of %d supported interfaces configured", count, iface_max)
)
else
warnings = string.format("%s
",
- translatef("WARNING: %d interfaces are configured exceeding the maximum of 250!", count)
+ translatef("WARNING: %d interfaces are configured exceeding the maximum of %d!", count, iface_max)
)
end
@@ -103,16 +104,43 @@ function configCheck()
end
end
)
- return overview, count
+
+ -- calculate iface_max usage from firewall mmx_mask
+ function bit(p)
+ return 2 ^ (p - 1)
+ end
+ function hasbit(x, p)
+ return x % (p + p) >= p
+ end
+ function setbit(x, p)
+ return hasbit(x, p) and x or x + p
+ end
+
+ local uci = require("uci").cursor(nil, "/var/state")
+ local mmx_mask = uci:get("mwan3", "globals", "mmx_mask") or "0x3F00"
+ local number = tonumber(mmx_mask, 16)
+ local bits = 0
+ local iface_max = 0
+ for i=1,16 do
+ if hasbit(number, bit(i)) then
+ bits = bits + 1
+ iface_max = setbit( iface_max, bit(bits))
+ end
+ end
+
+ -- subtract blackhole, unreachable and default table from iface_max
+ iface_max = iface_max - 3
+
+ return overview, count, iface_max
end
m5 = Map("mwan3", translate("MWAN - Interfaces"),
interfaceWarnings(configCheck()))
mwan_interface = m5:section(TypedSection, "interface", nil,
- translate("MWAN supports up to 250 physical and/or logical interfaces
" ..
+ translate("MWAN supports up to 252 physical and/or logical interfaces
" ..
"MWAN requires that all interfaces have a unique metric configured in /etc/config/network
" ..
- "Names must match the interface name found in /etc/config/network (see advanced tab)
" ..
+ "Names must match the interface name found in /etc/config/network
" ..
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces
" ..
"Interfaces may not share the same name as configured members, policies or rules"))
mwan_interface.addremove = true
@@ -142,7 +170,7 @@ track_method.rawhtml = true
function track_method.cfgvalue(self, s)
local tracked = self.map:get(s, "track_ip")
if tracked then
- return self.map:get(s, "track_method") or "—"
+ return self.map:get(s, "track_method") or "ping"
else
return "—"
end
@@ -153,7 +181,7 @@ reliability.rawhtml = true
function reliability.cfgvalue(self, s)
local tracked = self.map:get(s, "track_ip")
if tracked then
- return self.map:get(s, "reliability") or "—"
+ return self.map:get(s, "reliability") or "1"
else
return "—"
end
@@ -168,7 +196,7 @@ function interval.cfgvalue(self, s)
if intervalValue then
return intervalValue .. "s"
else
- return "—"
+ return "5s"
end
else
return "—"
@@ -180,7 +208,7 @@ down.rawhtml = true
function down.cfgvalue(self, s)
local tracked = self.map:get(s, "track_ip")
if tracked then
- return self.map:get(s, "down") or "—"
+ return self.map:get(s, "down") or "3"
else
return "—"
end
@@ -191,7 +219,7 @@ up.rawhtml = true
function up.cfgvalue(self, s)
local tracked = self.map:get(s, "track_ip")
if tracked then
- return self.map:get(s, "up") or "—"
+ return self.map:get(s, "up") or "3"
else
return "—"
end