1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add check for duplicate mac

This commit is contained in:
Ycarus (Yannick Chabanois) 2021-02-25 14:25:52 +01:00
parent 7c2fd8f2ad
commit a254d4aaed
2 changed files with 34 additions and 6 deletions

View file

@ -1105,6 +1105,7 @@ function interfaces_status()
mArray.wans = {}
mArray.tunnels = {}
allintf = {}
allmac = {}
uci:foreach("network", "interface", function (section)
local interface = section[".name"]
@ -1117,6 +1118,7 @@ function interfaces_status()
local enabled = section["auto"]
local proto = section["proto"] or ""
local ipv6 = section["ipv6"] or "0"
local mac = section ["macaddr"] or ""
--if not ipaddr or not gateway then return end
-- Don't show if0 in the overview
@ -1140,6 +1142,16 @@ function interfaces_status()
end
end
duplicatemac = false
if mac ~= "" and mac ~= nil and not (section["ifname"] ~= nil and section["ifname"]:match("^@.*")) then
if allmac[mac] then
connectivity = "ERROR"
duplicatemac = true
else
allmac[mac] = true
end
end
--if multipath == "off" and not ifname:match("^tun.*") then return end
if multipath == "off" then return end
@ -1237,7 +1249,7 @@ function interfaces_status()
if gateway ~= "" then
local gw_ping_test = ""
if ifname ~= "" and ifname ~= nil then
gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 -I " .. ifname .. " " .. gateway .. " | grep '100% packet loss'"))
gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 -B -I " .. ifname .. " " .. gateway .. " | grep '100% packet loss'"))
else
gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway .. " | grep '100% packet loss'"))
end
@ -1247,11 +1259,13 @@ function interfaces_status()
connectivity = "WARNING"
end
end
else
gw_ping = "DOWN"
end
if gateway6 ~= "" then
local gw_ping6_test = ""
if ifname ~= "" and ifname ~= nil then
gw_ping6_test = ut.trim(sys.exec("ping -w 1 -c 1 -I " .. ifname .. " " .. gateway6 .. " | grep '100% packet loss'"))
gw_ping6_test = ut.trim(sys.exec("ping -w 1 -c 1 -B -I " .. ifname .. " " .. gateway6 .. " | grep '100% packet loss'"))
else
gw_ping6_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway6 .. " | grep '100% packet loss'"))
end
@ -1261,6 +1275,8 @@ function interfaces_status()
connectivity = "WARNING"
end
end
else
gw_ping6 = "DOWN"
end
end
if uci:get("openmptcprouter", interface, "manufacturer") == "huawei" then
@ -1346,6 +1362,10 @@ function interfaces_status()
multipath_available = "NO CHECK"
end
local zonewan = "NO"
if ut.trim(sys.exec("uci -q get firewall.zone_wan.networks | grep '" .. interface .. "'")) ~= "" then
zonewan = "OK"
end
-- Detect if WAN get an IPv6
local ipv6_discover = "NONE"
@ -1449,6 +1469,7 @@ function interfaces_status()
multipath_available = multipath_available,
multipath_state = current_multipath_state,
duplicateif = duplicateif,
duplicatemac = duplicatemac,
signal = signal,
operator = operator,
phonenumber = phonenumber,
@ -1457,6 +1478,7 @@ function interfaces_status()
proto = proto,
rx = rx,
tx = tx,
zonewan = zonewan,
}
if ifname ~= nil and ifname:match("^tun.*") then
table.insert(mArray.tunnels, data);