summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2024-03-04 23:54:24 +0100
committerJo-Philipp Wich <jo@mein.io>2024-03-04 23:57:05 +0100
commitfa6c345e19360439fa5077137d1e927b0cc501d0 (patch)
treee4a89b5da9b093d37050f7b95a34b7b233146ab8
parent48e96d89557cbadfa03ffa351589b6d2273f1ed5 (diff)
luci-mod-status: fix sporadic logical interfaces resolve failures
Correct the incorrect netmask calculation logic leading to incorrect network range comparisons in some cases. Fixes: #6956 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js
index 8d7e36f701..dfe19fc70a 100644
--- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js
+++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js
@@ -13,13 +13,15 @@ var callNetworkInterfaceDump = rpc.declare({
function applyMask(addr, mask, v6) {
var words = v6 ? validation.parseIPv6(addr) : validation.parseIPv4(addr);
+ var bword = v6 ? 0xffff : 0xff;
+ var bwlen = v6 ? 16 : 8;
if (!words || mask < 0 || mask > (v6 ? 128 : 32))
return null;
for (var i = 0; i < words.length; i++) {
- var b = Math.min(mask, v6 ? 16 : 8);
- words[i] &= ((1 << b) - 1);
+ var b = Math.min(mask, bwlen);
+ words[i] &= (bword << (bwlen - b)) & bword;
mask -= b;
}