mirror of https://github.com/aredn/aredn.git
Fetch routes from kernel rather than OLSR (#1235)
* Fetch routes from kernel rather than OLSR Fix xlink detection * Fix commit
This commit is contained in:
parent
0328f0ec7e
commit
299645583c
|
@ -20,7 +20,7 @@ done
|
||||||
|
|
||||||
if [ "$(/sbin/uci -q get aredn.@lqm[0].min_quality)" = "50" ]; then
|
if [ "$(/sbin/uci -q get aredn.@lqm[0].min_quality)" = "50" ]; then
|
||||||
/sbin/uci -q set aredn.@lqm[0].min_quality=35
|
/sbin/uci -q set aredn.@lqm[0].min_quality=35
|
||||||
/sbin/uci -q -c /etc/config.mesh set aredn.@lqm[0].min_quality=35
|
|
||||||
/sbin/uci commit aredn
|
/sbin/uci commit aredn
|
||||||
|
/sbin/uci -q -c /etc/config.mesh set aredn.@lqm[0].min_quality=35
|
||||||
/sbin/uci -c /etc/config.mesh commit aredn
|
/sbin/uci -c /etc/config.mesh commit aredn
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -64,7 +64,7 @@ local IPCMD = "/sbin/ip"
|
||||||
local now = 0
|
local now = 0
|
||||||
local config = {}
|
local config = {}
|
||||||
|
|
||||||
local total_node_route_count = 0
|
local total_node_route_count = nil
|
||||||
|
|
||||||
function update_config()
|
function update_config()
|
||||||
local c = uci.cursor() -- each time as /etc/config/aredn may have changed
|
local c = uci.cursor() -- each time as /etc/config/aredn may have changed
|
||||||
|
@ -348,7 +348,6 @@ function lqm()
|
||||||
|
|
||||||
-- Find all our devices and know our macs so we can exclude them
|
-- Find all our devices and know our macs so we can exclude them
|
||||||
local devices = {}
|
local devices = {}
|
||||||
local our_macs = {}
|
|
||||||
for _, i in ipairs(nixio.getifaddrs())
|
for _, i in ipairs(nixio.getifaddrs())
|
||||||
do
|
do
|
||||||
if i.name then
|
if i.name then
|
||||||
|
@ -360,7 +359,6 @@ function lqm()
|
||||||
if i.family == "packet" then
|
if i.family == "packet" then
|
||||||
if i.addr then
|
if i.addr then
|
||||||
dev.mac = i.addr:lower()
|
dev.mac = i.addr:lower()
|
||||||
our_macs[dev.mac] = true
|
|
||||||
end
|
end
|
||||||
dev.tx_packets = i.data.tx_packets
|
dev.tx_packets = i.data.tx_packets
|
||||||
dev.tx_fail = i.data.tx_errors
|
dev.tx_fail = i.data.tx_errors
|
||||||
|
@ -398,7 +396,7 @@ function lqm()
|
||||||
-- Legacy and wireguard tunnels
|
-- Legacy and wireguard tunnels
|
||||||
for _, dev in pairs(devices)
|
for _, dev in pairs(devices)
|
||||||
do
|
do
|
||||||
if dev.name:match("^tun") then
|
if dev.name:match("^tun%d+") then
|
||||||
stations[#stations + 1] = {
|
stations[#stations + 1] = {
|
||||||
type = "Tunnel",
|
type = "Tunnel",
|
||||||
device = dev.name,
|
device = dev.name,
|
||||||
|
@ -407,7 +405,7 @@ function lqm()
|
||||||
tx_packets = dev.tx_packets,
|
tx_packets = dev.tx_packets,
|
||||||
tx_fail = dev.tx_fail
|
tx_fail = dev.tx_fail
|
||||||
}
|
}
|
||||||
elseif dev.name:match("^wgc") and wgtuns[dev.name] then
|
elseif dev.name:match("^wgc%d+") and wgtuns[dev.name] then
|
||||||
local ip123, ip4 = dev.ip:match("^(%d+%.%d+%.%d+%.)(%d+)$")
|
local ip123, ip4 = dev.ip:match("^(%d+%.%d+%.%d+%.)(%d+)$")
|
||||||
stations[#stations + 1] = {
|
stations[#stations + 1] = {
|
||||||
type = "Wireguard",
|
type = "Wireguard",
|
||||||
|
@ -417,7 +415,7 @@ function lqm()
|
||||||
tx_packets = dev.tx_packets,
|
tx_packets = dev.tx_packets,
|
||||||
tx_fail = dev.tx_fail
|
tx_fail = dev.tx_fail
|
||||||
}
|
}
|
||||||
elseif dev.name:match("^wgs") and wgtuns[dev.name] then
|
elseif dev.name:match("^wgs%d+") and wgtuns[dev.name] then
|
||||||
local ip123, ip4 = dev.ip:match("^(%d+%.%d+%.%d+%.)(%d+)$")
|
local ip123, ip4 = dev.ip:match("^(%d+%.%d+%.%d+%.)(%d+)$")
|
||||||
stations[#stations + 1] = {
|
stations[#stations + 1] = {
|
||||||
type = "Wireguard",
|
type = "Wireguard",
|
||||||
|
@ -430,7 +428,17 @@ function lqm()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- DtD
|
-- Xlink interfaces
|
||||||
|
local xlinks = {}
|
||||||
|
cursorm:foreach("xlink", "interface",
|
||||||
|
function(section)
|
||||||
|
if section.ifname then
|
||||||
|
xlinks[section.ifname] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
-- DtD & Xlinks
|
||||||
for _, entry in ipairs(arps)
|
for _, entry in ipairs(arps)
|
||||||
do
|
do
|
||||||
if entry.Device:match("%.2$") or entry.Device:match("^br%-dtdlink") then
|
if entry.Device:match("%.2$") or entry.Device:match("^br%-dtdlink") then
|
||||||
|
@ -440,25 +448,15 @@ function lqm()
|
||||||
ip = entry["IP address"],
|
ip = entry["IP address"],
|
||||||
mac = entry["HW address"]
|
mac = entry["HW address"]
|
||||||
}
|
}
|
||||||
end
|
elseif xlinks[entry.Device] then
|
||||||
end
|
|
||||||
|
|
||||||
-- Xlink
|
|
||||||
cursorm:foreach("xlink", "interface",
|
|
||||||
function(section)
|
|
||||||
if section.ifname then
|
|
||||||
local entry = devices[section.ifname]
|
|
||||||
if entry then
|
|
||||||
stations[#stations + 1] = {
|
stations[#stations + 1] = {
|
||||||
type = "Xlink",
|
type = "Xlink",
|
||||||
device = entry.name,
|
device = entry.Device,
|
||||||
ip = entry.ip,
|
ip = entry["IP address"],
|
||||||
mac = entry.mac
|
mac = entry["HW address"]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
-- RF
|
-- RF
|
||||||
if radiomode == "adhoc" then
|
if radiomode == "adhoc" then
|
||||||
|
@ -483,7 +481,7 @@ function lqm()
|
||||||
type = "RF",
|
type = "RF",
|
||||||
device = wlan,
|
device = wlan,
|
||||||
mac = mac:lower(),
|
mac = mac:lower(),
|
||||||
signal = 0,
|
signal = nil,
|
||||||
noise = noise,
|
noise = noise,
|
||||||
ip = nil,
|
ip = nil,
|
||||||
tx_bitrate = 0,
|
tx_bitrate = 0,
|
||||||
|
@ -496,7 +494,6 @@ function lqm()
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
stations[#stations + 1] = station
|
|
||||||
else
|
else
|
||||||
for k, v in pairs(kv)
|
for k, v in pairs(kv)
|
||||||
do
|
do
|
||||||
|
@ -506,6 +503,9 @@ function lqm()
|
||||||
if v == "tx_bitrate" or v == "rx_bitrate" then
|
if v == "tx_bitrate" or v == "rx_bitrate" then
|
||||||
station[v] = station[v] * channel_bw_scale
|
station[v] = station[v] * channel_bw_scale
|
||||||
end
|
end
|
||||||
|
if v == "signal" then
|
||||||
|
stations[#stations + 1] = station
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -515,7 +515,6 @@ function lqm()
|
||||||
-- Update the trackers based on the latest station information
|
-- Update the trackers based on the latest station information
|
||||||
for _, station in ipairs(stations)
|
for _, station in ipairs(stations)
|
||||||
do
|
do
|
||||||
if station.signal ~= 0 and not our_macs[station.mac] then
|
|
||||||
if not tracker[station.mac] then
|
if not tracker[station.mac] then
|
||||||
tracker[station.mac] = {
|
tracker[station.mac] = {
|
||||||
type = station.type,
|
type = station.type,
|
||||||
|
@ -599,7 +598,6 @@ function lqm()
|
||||||
|
|
||||||
track.lastseen = now
|
track.lastseen = now
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- Update link tracking state
|
-- Update link tracking state
|
||||||
local ip2tracker = {}
|
local ip2tracker = {}
|
||||||
|
@ -804,17 +802,17 @@ function lqm()
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Pull in the routing table to see how many node routes are associated with each tracker.
|
-- Pull in the routing table to see how many node routes are associated with each tracker.
|
||||||
-- We dont do this if this is a supernode because the routes table is massive and can cause
|
-- We don't do this for supernodes as the table is very big and we don't use the information.
|
||||||
-- crash olsrd.
|
-- Don't pull the data from OLSR as this can be too distruptive to its operation on slower nodes
|
||||||
|
-- with large routing tables.
|
||||||
--
|
--
|
||||||
total_node_route_count = 0
|
|
||||||
if not is_supernode then
|
if not is_supernode then
|
||||||
for _, route in ipairs(aredn.olsr.getOLSRRoutes())
|
total_node_route_count = 0
|
||||||
|
for line in io.popen(IPCMD .. " route show table 30"):lines()
|
||||||
do
|
do
|
||||||
-- Count routes to nodes. There are two routes to most nodes, the node's primary address
|
local gw = line:match("^10%.%d+%.%d+%.%d+ via (%d+%.%d+%.%d+%.%d+) dev")
|
||||||
-- and the node's dtdlink address.
|
if gw then
|
||||||
if route.genmask == 32 and route.destination:match("^10%.") then
|
local track = ip2tracker[gw];
|
||||||
local track = ip2tracker[route.gateway];
|
|
||||||
if track then
|
if track then
|
||||||
track.node_route_count = track.node_route_count + 1
|
track.node_route_count = track.node_route_count + 1
|
||||||
total_node_route_count = total_node_route_count + 1
|
total_node_route_count = total_node_route_count + 1
|
||||||
|
|
Loading…
Reference in New Issue