From 406d2ca0e2fb3d53f31e6a6b12f0646348efb275 Mon Sep 17 00:00:00 2001 From: Ycarus Date: Fri, 12 Oct 2018 10:49:56 +0200 Subject: [PATCH] Check if a network interface is not used multiple times --- .../luasrc/controller/openmptcprouter.lua | 14 ++++++++++++-- .../luasrc/view/openmptcprouter/wanstatus.htm | 6 ++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua index 443bbdc53..4e853652e 100644 --- a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua +++ b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua @@ -32,7 +32,6 @@ function interface_from_device(dev) return "" end - function wizard_add() local add_interface = luci.http.formvalue("add_interface") or "" local add_interface_ifname = luci.http.formvalue("add_interface_ifname") or "" @@ -650,6 +649,7 @@ function interfaces_status() -- overview status mArray.wans = {} mArray.tunnels = {} + allintf = {} uci:foreach("network", "interface", function (section) local interface = section[".name"] @@ -667,7 +667,16 @@ function interfaces_status() if ifname == "" then ifname = get_device(interface) end - + duplicateif = false + if ifname ~= "" and ifname ~= nil then + if allintf[ifname] then + connectivity = "ERROR" + duplicateif = true + else + allintf[ifname] = true + end + end + --if multipath == "off" and not ifname:match("^tun.*") then return end if multipath == "off" then return end @@ -825,6 +834,7 @@ function interfaces_status() server_ping = server_ping, ipv6_discover = ipv6_discover, multipath_available = multipath_available, + duplicateif = duplicateif, } if ifname ~= nil and ifname:match("^tun.*") then diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm index 20ed81122..6c61c5866 100644 --- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm +++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm @@ -226,6 +226,7 @@ var server_ping = mArray.wans[i].server_ping; var ipv6_discover = mArray.wans[i].ipv6_discover; var multipath_available = mArray.wans[i].multipath_available; + var duplicateif = mArray.wans[i].duplicateif; // Generate template if(mArray.openmptcprouter.remote_from_lease == true && mArray.wans.length == 1) { @@ -277,6 +278,11 @@ statusMessage += 'Multipath master already defined
'; statusMessageClass = "error"; } + if(duplicateif) + { + statusMessage += 'Network interface duplicated
'; + statusMessageClass = "error"; + } if(ipv6_discover == 'DETECTED') { statusMessage += 'IPv6 route received
'