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>
This commit is contained in:
parent
48e96d8955
commit
fa6c345e19
1 changed files with 4 additions and 2 deletions
|
@ -13,13 +13,15 @@ var callNetworkInterfaceDump = rpc.declare({
|
||||||
|
|
||||||
function applyMask(addr, mask, v6) {
|
function applyMask(addr, mask, v6) {
|
||||||
var words = v6 ? validation.parseIPv6(addr) : validation.parseIPv4(addr);
|
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))
|
if (!words || mask < 0 || mask > (v6 ? 128 : 32))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
for (var i = 0; i < words.length; i++) {
|
for (var i = 0; i < words.length; i++) {
|
||||||
var b = Math.min(mask, v6 ? 16 : 8);
|
var b = Math.min(mask, bwlen);
|
||||||
words[i] &= ((1 << b) - 1);
|
words[i] &= (bword << (bwlen - b)) & bword;
|
||||||
mask -= b;
|
mask -= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue