From af539fc577f691984c08d984b81de685032bac3c Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Sat, 14 Dec 2024 15:05:53 +0100 Subject: [PATCH] gluon-core: if last mac-address byte overflows - let it overflow --- package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua index b0bf7efca4..354e94bd07 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua @@ -194,7 +194,6 @@ function M.generate_mac(i) local m1, m2, m3, m4, m5, m6 = string.match(hashed, '(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)') m1 = tonumber(m1, 16) - m5 = tonumber(m5, 16) m6 = tonumber(m6, 16) m1 = bit.bor(m1, 0x02) -- set locally administered bit @@ -205,12 +204,10 @@ function M.generate_mac(i) -- a hardware MAC filter. (e.g 'rt305x') m6 = bit.band(m6, 0xF8) -- zero the last three bits (space needed for counting) - m6 = m6 + i -- add virtual interface id + m6 = math.fmod(m6 + i, 256) -- add virtual interface id - local overflow = math.floor(i/8) - m5 = math.fmod(m5 + overflow, 256) - return string.format('%02x:%s:%s:%s:%02x:%02x', m1, m2, m3, m4, m5, m6) + return string.format('%02x:%s:%s:%s:%s:%02x', m1, m2, m3, m4, m5, m6) end function M.get_uptime()