Skip to content
Snippets Groups Projects
Commit 4e5b3354 authored by Jan-Philipp Litza's avatar Jan-Philipp Litza
Browse files

gluon-mesh-batman-adv-core: Only announce valid IPv6 addresses

The nodeinfo/network/addresses announcement included deprecated and
tentative addresses, which it clearly shouldn't as the host doesn't want
to be contacted on those addresses. They are now filtered out.
parent bf2f4880
No related branches found
No related tags found
No related merge requests found
local ip = require 'luci.ip' local ip = require 'luci.ip'
local bit = require 'nixio'.bit
local addresses = {} local addresses = {}
for line in io.lines('/proc/net/if_inet6') do for line in io.lines('/proc/net/if_inet6') do
local matches = { line:match('^' .. string.rep('(%x%x%x%x)', 8) .. string.rep(' %x%x', 4) .. '%s+([^%s]+)$') } local matches = { line:match('^' .. string.rep('(%x%x%x%x)', 8) .. string.rep(' %x%x', 3) .. ' (%x%x)%s+([^%s]+)$') }
if matches[9] == 'br-client' then -- exclude wrong interfaces and deprecated as well as tentative addresses
-- (see /include/uapi/linux/if_addr.h in linux source for flags)
if matches[10] == 'br-client' and bit.band(tonumber(matches[9], 16), 0x60) == 0 then
table.insert(addresses, ip.IPv6(string.format('%s:%s:%s:%s:%s:%s:%s:%s', unpack(matches))):string():lower()) table.insert(addresses, ip.IPv6(string.format('%s:%s:%s:%s:%s:%s:%s:%s', unpack(matches))):string():lower())
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment