From ea850cea047c99cdec43954b183e4a0c4f367230 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Thu, 28 Jan 2021 20:43:31 +0100 Subject: [PATCH] Support alias interfaces --- .../root/usr/libexec/rpcd/openmptcprouter | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter b/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter index 9f88a0cc4..b80a81a7d 100755 --- a/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter +++ b/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter @@ -1115,6 +1115,7 @@ function interfaces_status() local gateway6 = section["ip6gw"] or "" local multipath = section["multipath"] local enabled = section["auto"] + local proto = section["proto"] or "" --if not ipaddr or not gateway then return end -- Don't show if0 in the overview @@ -1130,7 +1131,7 @@ function interfaces_status() duplicateif = false if ifname ~= "" and ifname ~= nil then - if allintf[ifname] then + if allintf[ifname] and not section["ifname"]:match("^@.*") then connectivity = "ERROR" duplicateif = true else @@ -1144,10 +1145,10 @@ function interfaces_status() if enabled == "0" then return end local connectivity = "OK" - if ipaddr == "" and ifname ~= nil and ifname ~= "" then + if ipaddr == "" and ifname ~= nil and ifname ~= "" and proto ~= "dhcpv6" then ipaddr = ut.trim(sys.exec("ip -4 -br addr ls dev " .. ifname .. " | awk -F'[ /]+' '{print $3}' | tr -d '\n'")) end - if ipaddr == "" and ifname ~= nil and ifname ~= "" then + if ipaddr == "" and ifname ~= nil and ifname ~= "" and proto ~= "dhcpv6" then ipaddr = ut.trim(sys.exec("ip -4 addr show dev " .. ifname .. " | grep -m 1 inet | awk '{print $2}' | cut -d'/' -s -f1 | tr -d '\n'")) end if ip6addr == "" and ifname ~= nil and ifname ~= "" then @@ -1195,14 +1196,16 @@ function interfaces_status() local gw_ping = "UP" local gw_ping6 = "UP" if ifname ~= nil and not (ifname:match("^tun.*") or interface:match("^ovpn.*")) then - gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'")) + if proto ~= "dhcpv6" then + gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'")) + end gateway6 = ut.trim(sys.exec("ip -6 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'")) end - if gateway == "" then + if gateway == "" and proto ~= "dhcpv6" then gateway = get_gateway(interface) end - if gateway == "" and ifname ~= nil and ifname ~= "" then + if gateway == "" and ifname ~= nil and ifname ~= "" and proto ~= "dhcpv6" then if fs.access("/sys/class/net/" .. ifname) then gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep kernel | awk '/proto kernel/ {print $1}' | grep -v / | tr -d '\n'")) if gateway == "" then @@ -1263,7 +1266,7 @@ function interfaces_status() end if ifname ~= "" and ifname ~= nil then - local proto = section['proto'] + --local proto = section['proto'] if proto == "qmi" then local device = section['device'] intfdata = ut.trim(sys.exec("omr-qmi " .. device .. " all")) @@ -1438,6 +1441,7 @@ function interfaces_status() phonenumber = phonenumber, donglestate = donglestate, networktype = networktype, + proto = proto, rx = rx, tx = tx, }