From 1f15378d567ae410702de87a6d496f62ef2aca5e Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 25 Jun 2021 19:39:19 +0200 Subject: [PATCH 01/11] Change VPN to use device instead of ifname --- dsvpn/files/init | 2 +- glorytun-udp/init | 2 +- glorytun/init | 2 +- mlvpn/files/etc/init.d/mlvpn | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dsvpn/files/init b/dsvpn/files/init index 250c409df..1d78ed4be 100755 --- a/dsvpn/files/init +++ b/dsvpn/files/init @@ -49,7 +49,7 @@ start_instance() { key="" if [ "$(uci -q get network.omrvpn)" != "" ] && [ "$(uci -q get network.omrvpn)" != "$dev" ]; then - uci -q set network.omrvpn.ifname=$dev + uci -q set network.omrvpn.device=$dev uci -q commit fi diff --git a/glorytun-udp/init b/glorytun-udp/init index e9f7caf7c..f5086024f 100755 --- a/glorytun-udp/init +++ b/glorytun-udp/init @@ -50,7 +50,7 @@ start_instance() { key="" if [ "$(uci -q get network.omrvpn)" != "" ]; then - uci -q set network.omrvpn.ifname=$dev + uci -q set network.omrvpn.device=$dev uci -q commit fi diff --git a/glorytun/init b/glorytun/init index f5b868323..3d549f0aa 100755 --- a/glorytun/init +++ b/glorytun/init @@ -59,7 +59,7 @@ start_instance() { key="" if [ "$(uci -q get network.omrvpn)" != "" ]; then - uci -q set network.omrvpn.ifname=${dev} + uci -q set network.omrvpn.device=${dev} uci -q commit network fi _log "starting ${PROG_NAME} ${1} instance $*" diff --git a/mlvpn/files/etc/init.d/mlvpn b/mlvpn/files/etc/init.d/mlvpn index 6ef4bfdc6..33f6e75a9 100755 --- a/mlvpn/files/etc/init.d/mlvpn +++ b/mlvpn/files/etc/init.d/mlvpn @@ -13,7 +13,8 @@ interface_multipath_settings() { mode="$(uci -q get openmptcprouter.$config.multipath)" } [ "$mode" = "off" ] || [ "$mode" = "" ] && return 1 - config_get ifname "$config" ifname + config_get ifname "$config" device + [ -z "$ifname" ] && config_get ifname "$config" ifname [ -z "$ifname" ] && ifname=$(ifstatus "$config" | jsonfilter -q -e '@["l3_device"]') [ -n "$(echo $ifname | grep '@')" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["device"]') [ -z "$ifname" ] && return 1 @@ -46,7 +47,7 @@ start() { firstport="$(uci -q get mlvpn.general.firstport)" if [ "$(uci -q get network.omrvpn)" != "${interface_name}" ]; then - uci -q set network.omrvpn.ifname=${interface_name} + uci -q set network.omrvpn.device=${interface_name} uci -q commit fi From 04b15901fa627b77c46756e3289166f07e480c88 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 25 Jun 2021 19:40:55 +0200 Subject: [PATCH 02/11] Change luci glorytun interface to use device instead of ifname uci setting --- luci-app-glorytun-tcp/root/etc/uci-defaults/1200-luci-glorytun | 2 +- .../root/etc/uci-defaults/1201-luci-glorytun-udp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/luci-app-glorytun-tcp/root/etc/uci-defaults/1200-luci-glorytun b/luci-app-glorytun-tcp/root/etc/uci-defaults/1200-luci-glorytun index 9d0f93d85..a15f491be 100644 --- a/luci-app-glorytun-tcp/root/etc/uci-defaults/1200-luci-glorytun +++ b/luci-app-glorytun-tcp/root/etc/uci-defaults/1200-luci-glorytun @@ -15,7 +15,7 @@ if [ "$(uci -q get network.glorytun)" = "" ] && [ "$(uci -q get network.omrvpn)" uci -q batch <<-EOF >/dev/null delete network.glorytun set network.glorytun=interface - set network.glorytun.ifname=tun0 + set network.glorytun.device=tun0 set network.glorytun.proto=dhcp set network.glorytun.ip4table=vpn set network.glorytun.multipath=off diff --git a/luci-app-glorytun-udp/root/etc/uci-defaults/1201-luci-glorytun-udp b/luci-app-glorytun-udp/root/etc/uci-defaults/1201-luci-glorytun-udp index dbecf5b5b..ebe335318 100644 --- a/luci-app-glorytun-udp/root/etc/uci-defaults/1201-luci-glorytun-udp +++ b/luci-app-glorytun-udp/root/etc/uci-defaults/1201-luci-glorytun-udp @@ -11,7 +11,7 @@ if [ "$(uci -q get network.glorytun-udp)" = "" ] && [ "$(uci -q get network.omrv uci -q batch <<-EOF >/dev/null delete network.glorytun-udp set network.glorytun-udp=interface - set network.glorytun-udp.ifname=tun0 + set network.glorytun-udp.device=tun0 set network.glorytun-udp.proto=dhcp set network.glorytun-udp.ip4table=vpn set network.glorytun-udp.multipath=off From 72f5756eb5949de5c838b7948c97652225f2f37c Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 25 Jun 2021 19:42:03 +0200 Subject: [PATCH 03/11] Change in luci-app-openmptcprouter to use device setting --- .../luasrc/controller/openmptcprouter.lua | 46 +++++++++++++++---- .../luasrc/view/openmptcprouter/wizard.htm | 8 ++-- .../root/etc/init.d/openmptcprouter | 6 ++- .../root/usr/libexec/rpcd/openmptcprouter | 21 +++++---- 4 files changed, 58 insertions(+), 23 deletions(-) diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua index 3d243b210..cca82d950 100644 --- a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua +++ b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua @@ -26,7 +26,11 @@ end function interface_from_device(dev) for _, iface in ipairs(net:get_networks()) do local ifacen = iface:name() - local ifacename = ucic:get("network",ifacen,"ifname") + local ifacename = "" + ifacename = ucic:get("network",ifacen,"device") + if ifacename == "" then + ifacename = ucic:get("network",ifacen,"ifname") + end if ifacename == dev then return ifacen end @@ -113,7 +117,10 @@ function wizard_add() end) local defif = "eth0" if add_interface_ifname == "" then - local defif1 = ucic:get("network","wan1_dev","ifname") or "" + local defif1 = ucic:get("network","wan1_dev","device") or "" + if defif1 == "" then + defif1 = ucic:get("network","wan1_dev","ifname") or "" + end if defif1 ~= "" then defif = defif1 end @@ -126,17 +133,29 @@ function wizard_add() if ointf ~= "" then if ucic:get("network",ointf,"type") == "" then ucic:set("network",ointf,"type","macvlan") + ucic:set("network",ointf,"device",ointf) + ucic:set("network",ointf .. "_dev","device") + ucic:set("network",ointf .. "_dev","type","macvlan") + ucic:set("network",ointf .. "_dev","mode","vepa") + ucic:set("network",ointf .. "_dev","ifname",defif) + ucic:set("network",ointf .. "_dev","name",ointf) end wanif = "wan" .. i end ucic:set("network","wan" .. i,"interface") - ucic:set("network","wan" .. i,"ifname",defif) + ucic:set("network","wan" .. i,"device",defif) ucic:set("network","wan" .. i,"proto","static") ucic:set("openmptcprouter","wan" .. i,"interface") if ointf ~= "" then ucic:set("network","wan" .. i,"type","macvlan") + ucic:set("network","wan" .. i,"device","wan" .. i) ucic:set("network","wan" .. i,"masterintf",defif) + ucic:set("network","wan" .. i .. "_dev","device") + ucic:set("network","wan" .. i .. "_dev","type","macvlan") + ucic:set("network","wan" .. i .. "_dev","mode","vepa") + ucic:set("network","wan" .. i .. "_dev","ifname",defif) + ucic:set("network","wan" .. i .. "_dev","name","wan" .. i) end ucic:set("network","wan" .. i,"ip4table","wan") if multipath_master then @@ -197,7 +216,10 @@ function wizard_add() local delete_intf = luci.http.formvaluetable("delete") or "" if delete_intf ~= "" then for intf, _ in pairs(delete_intf) do - local defif = ucic:get("network",intf,"ifname") + local defif = ucic:get("network",intf,"ifname") or "" + if defif == "" then + defif = ucic:get("network",intf,"ifname") + end ucic:delete("network",intf) if ucic:get("network",intf .. "_dev") ~= "" then ucic:delete("network",intf .. "_dev") @@ -262,9 +284,14 @@ function wizard_add() end if typeintf == "macvlan" and masterintf ~= "" then ucic:set("network",intf,"type","macvlan") + ucic:set("network",intf .. "_dev","device") + ucic:set("network",intf .. "_dev","type","macvlan") + ucic:set("network",intf .. "_dev","ifname",masterinf) + ucic:set("network",intf .. "_dev","mode","vepa") + ucic:set("network",intf .. "_dev","name",intf) ucic:set("network",intf,"masterintf",masterintf) elseif typeintf == "" and ifname ~= "" and (proto == "static" or proto == "dhcp" or proto == "dhcpv6") then - ucic:set("network",intf,"ifname",ifname) + ucic:set("network",intf,"device",ifname) elseif typeintf == "" and device ~= "" and proto == "ncm" then ucic:set("network",intf,"device",device_ncm) elseif typeintf == "" and device ~= "" and proto == "qmi" then @@ -342,7 +369,10 @@ function wizard_add() if not ucic:get("sqm",intf) ~= "" then local defif = get_device(intf) if defif == "" then - defif = ucic:get("network",intf,"ifname") or "" + defif = ucic:get("network",intf,"device") or "" + if defif == "" then + defif = ucic:get("network",intf,"ifname") or "" + end end ucic:set("sqm",intf,"queue") ucic:set("sqm",intf,"interface",defif) @@ -442,7 +472,7 @@ function wizard_add() ucic:set("network","omrvpn","proto","bonding") end if vpn_intf ~= "" then - ucic:set("network","omrvpn","ifname",vpn_intf) + ucic:set("network","omrvpn","device",vpn_intf) ucic:set("sqm","omrvpn","interface",vpn_intf) ucic:save("network") ucic:commit("network") @@ -894,7 +924,7 @@ function wizard_add() -- Restart all menuentry = ucic:get("openmptcprouter","settings","menu") or "openmptcprouter" if gostatus == true then - luci.sys.call("/etc/init.d/macvlan restart >/dev/null 2>/dev/null") + --luci.sys.call("/etc/init.d/macvlan restart >/dev/null 2>/dev/null") luci.sys.call("(env -i /bin/ubus call network reload) >/dev/null 2>/dev/null") luci.sys.call("ip addr flush dev tun0 >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/omr-tracker stop >/dev/null 2>/dev/null") diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm index 2c33cfa2d..13cbffcf2 100644 --- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm +++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm @@ -473,7 +473,7 @@ if not (ifacea == "lo" or ifacea == "6in4-omr6in4" or ifacea == "mlvpn0" or ifacea:match("^ifb.*") or ifacea:match("^sit.*") or ifacea:match("^gre.*") or ifacea:match("^ip6.*") or ifacea:match("^teql.*") or ifacea:match("^erspan.*") or ifacea:match("^tun.*") or ifacea:match("^bond.*")) and device_notvirtual(ifacea) then if uci:get("network",ifname,"proto") ~= "macvlan" then %> - + <% else %> @@ -483,9 +483,9 @@ end end if uci:get("network",ifname,"proto") ~= "macvlan" then - if iffind == 0 and uci:get("network",ifname,"ifname") ~= nil then + if iffind == 0 and uci:get("network",ifname,"device") ~= nil then %> - + <% end else @@ -616,7 +616,7 @@