From 7adc290974b7089b39b23a32dbb4f218002d7a64 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 8 Aug 2023 12:49:14 +0200 Subject: [PATCH 1/6] Various changes for 6.1 in MPTCP Luci interface --- luci-app-mptcp/luasrc/controller/mptcp.lua | 6 ++---- luci-app-mptcp/luasrc/model/cbi/mptcp.lua | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/luci-app-mptcp/luasrc/controller/mptcp.lua b/luci-app-mptcp/luasrc/controller/mptcp.lua index 89bc92c13..842adc6ef 100644 --- a/luci-app-mptcp/luasrc/controller/mptcp.lua +++ b/luci-app-mptcp/luasrc/controller/mptcp.lua @@ -15,10 +15,8 @@ function index() entry({"admin", "network", "mptcp", "mptcp_check_trace"}, post("mptcp_check_trace")).leaf = true entry({"admin", "network", "mptcp", "mptcp_fullmesh"}, template("mptcp/mptcp_fullmesh"), _("MPTCP Fullmesh"), 5).leaf = true entry({"admin", "network", "mptcp", "mptcp_fullmesh_data"}, post("mptcp_fullmesh_data")).leaf = true - if nixio.uname().release:sub(1,4) ~= "5.15" and nixio.uname().release:sub(1,1) ~= "6" then - entry({"admin", "network", "mptcp", "mptcp_connections"}, template("mptcp/mptcp_connections"), _("Established connections"), 6).leaf = true - entry({"admin", "network", "mptcp", "mptcp_connections_data"}, post("mptcp_connections_data")).leaf = true - end + entry({"admin", "network", "mptcp", "mptcp_connections"}, template("mptcp/mptcp_connections"), _("Established connections"), 6).leaf = true + entry({"admin", "network", "mptcp", "mptcp_connections_data"}, post("mptcp_connections_data")).leaf = true entry({"admin", "network", "mptcp", "mptcp_monitor"}, template("mptcp/mptcp_monitor"), _("MPTCP monitoring"), 6).leaf = true entry({"admin", "network", "mptcp", "mptcp_monitor_data"}, post("mptcp_monitor_data")).leaf = true end diff --git a/luci-app-mptcp/luasrc/model/cbi/mptcp.lua b/luci-app-mptcp/luasrc/model/cbi/mptcp.lua index d5fe52f9c..e8f827bee 100644 --- a/luci-app-mptcp/luasrc/model/cbi/mptcp.lua +++ b/luci-app-mptcp/luasrc/model/cbi/mptcp.lua @@ -15,9 +15,13 @@ o:value("disable", translate("disable")) o = s:option(ListValue, "mptcp_checksum", translate("Multipath TCP checksum")) o:value(1, translate("enable")) o:value(0, translate("disable")) -o = s:option(ListValue, "mptcp_debug", translate("Multipath Debug")) -o:value(1, translate("enable")) -o:value(0, translate("disable")) + +if uname.release:sub(1,4) ~= "5.15" and uname.release:sub(1,1) ~= "6" then + o = s:option(ListValue, "mptcp_debug", translate("Multipath Debug")) + o:value(1, translate("enable")) + o:value(0, translate("disable")) +end + o = s:option(ListValue, "mptcp_path_manager", translate("Multipath TCP path-manager"), translate("Default is fullmesh")) o:value("default", translate("default")) o:value("fullmesh", "fullmesh") @@ -61,12 +65,17 @@ end -- if tonumber(uname.release:sub(1,4)) >= 5.15 then if uname.release:sub(1,4) == "5.15" or uname.release:sub(1,1) == "6" then + o = s:option(ListValue, "mptcp_pm_type", translate("Path Manager type")) + o:value(0, translate("In-kernel path manager")) + o:value(1, translate("Userspace path manager")) + o.default = 0 + o = s:option(Value, "mptcp_subflows", translate("Max subflows"),translate("specifies the maximum number of additional subflows allowed for each MPTCP connection")) o.datatype = "uinteger" o.rmempty = false o.default = 3 - o = s:option(Value, "mptcp_stale_loss_cnt", translate("Retranmission intervals"),translate("The number of MPTCP-level retransmission intervals with no traffic and pending outstanding data on a given subflow required to declare it stale")) + o = s:option(Value, "mptcp_stale_loss_cnt", translate("Retranmission intervals"),translate("The number of MPTCP-level retransmission intervals with no traffic and pending outstanding data on a given subflow required to declare it stale. A low stale_loss_cnt value allows for fast active-backup switch-over, an high value maximize links utilization on edge scenarios e.g. lossy link with high BER or peer pausing the data processing.")) o.datatype = "uinteger" o.rmempty = false o.default = 4 From 19b447669e8cdab1124adb1a38d1aa138e0f9717 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 8 Aug 2023 12:49:45 +0200 Subject: [PATCH 2/6] Fix on MPTCP settings --- mptcp/files/etc/init.d/mptcp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mptcp/files/etc/init.d/mptcp b/mptcp/files/etc/init.d/mptcp index d83b12b1d..5c0c43d8e 100755 --- a/mptcp/files/etc/init.d/mptcp +++ b/mptcp/files/etc/init.d/mptcp @@ -50,6 +50,10 @@ global_multipath_settings() { elif [ -f /proc/sys/net/mptcp/enabled ]; then sysctl -qew net.mptcp.enabled="$multipath_status" ip mptcp limits set add_addr_accepted $mptcp_add_addr_accepted subflows $mptcp_subflows 2>&1 >/dev/null + #[ -z "$mptcp_debug" ] || sysctl -qew net.mptcp.mptcp_debug="$mptcp_debug" + [ -z "$mptcp_checksum" ] || sysctl -qew net.mptcp.mptcp_checksum="$mptcp_checksum" + [ -z "$mptcp_path_manager" ] || sysctl -qew net.mptcp.mptcp_path_manager="$mptcp_path_manager" + [ -z "$mptcp_scheduler" ] || sysctl -qew net.mptcp.mptcp_scheduler="$mptcp_scheduler" [ -z "$mptcp_add_addr_timeout" ] || sysctl -qew net.mptcp.add_addr_timeout="$mptcp_add_addr_timeout" [ -z "$mptcp_checksum" ] || sysctl -qew net.mptcp.checksum_enabled="$mptcp_checksum" [ -z "$mptcp_stale_loss_cnt" ] || sysctl -qew net.mptcp.stale_loss_cnt="$mptcp_stale_loss_cnt" From da603e93109584d86da7c27c62334c170f75d27c Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 8 Aug 2023 12:50:39 +0200 Subject: [PATCH 3/6] Add upload support to server speed test --- openmptcprouter/files/bin/omr-test-speed | 29 +++++++++---- .../files/bin/omr-test-speed-server | 42 ++++++++++++++----- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/openmptcprouter/files/bin/omr-test-speed b/openmptcprouter/files/bin/omr-test-speed index ab8e1a929..2aaf3b72b 100755 --- a/openmptcprouter/files/bin/omr-test-speed +++ b/openmptcprouter/files/bin/omr-test-speed @@ -1,19 +1,25 @@ #!/bin/sh -# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 : +# (c) Yannick Chabanois (ycarus@zugaina.org) for OpenMPTCProuter +# +# + FORCEVPS=false +FASTTEST=false if [ "$1" = "forcevps" ]; then - INTERFACE="$2" FORCEVPS=true -else - INTERFACE="$1" fi +if [ "$1" = "fasttest" ]; then + FASTTEST=true +fi +for i in $@; do :; done +INTERFACE="$i" [ -n "$INTERFACE" ] && [ ! -d "/sys/class/net/$INTERFACE" ] && { echo "You must use a real interface. You wan find them using 'ip a' for example" exit 0 } -echo "Select best test server..." +[ "$FASTTEST" ] || echo "Select best test server..." HOSTLST="http://scaleway.testdebit.info/10G.iso http://bordeaux.testdebit.info/10G.iso http://aix-marseille.testdebit.info/10G.iso http://lyon.testdebit.info/10G.iso http://lille.testdebit.info/10G.iso http://paris.testdebit.info/10G.iso http://appliwave.testdebit.info/10G/10G.iso http://speedtest.frankfurt.linode.com/garbage.php?ckSize=10000 http://speedtest.tokyo2.linode.com/garbage.php?ckSize=10000 http://speedtest.singapore.linode.com/garbage.php?ckSize=10000 http://speedtest.newark.linode.com/garbage.php?ckSize=10000 http://speedtest.atlanta.linode.com/garbage.php?ckSize=10000 http://speedtest.dallas.linode.com/garbage.php?ckSize=10000 http://speedtest.fremont.linode.com/garbage.php?ckSize=10000 https://speed.hetzner.de/10GB.bin http://ipv4.bouygues.testdebit.info/10G.iso http://par.download.datapacket.com/10000mb.bin http://nyc.download.datapacket.com/10000mb.bin http://ams.download.datapacket.com/10000mb.bin http://fra.download.datapacket.com/10000mb.bin http://lon.download.datapacket.com/10000mb.bin http://mad.download.datapacket.com/10000mb.bin http://prg.download.datapacket.com/10000mb.bin http://sto.download.datapacket.com/10000mb.bin http://vie.download.datapacket.com/10000mb.bin http://war.download.datapacket.com/10000mb.bin http://atl.download.datapacket.com/10000mb.bin http://chi.download.datapacket.com/10000mb.bin http://lax.download.datapacket.com/10000mb.bin http://mia.download.datapacket.com/10000mb.bin http://nyc.download.datapacket.com/10000mb.bin http://speedtest.milkywan.fr/files/10G.iso" bestping="9999" for pinghost in $HOSTLST; do @@ -23,7 +29,7 @@ for pinghost in $HOSTLST; do else ping=$(ping -4 -c1 -w2 -I $INTERFACE -B $domain | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') fi - echo "host: $domain - ping: $ping" + [ "$FASTTEST" ] || echo "host: $domain - ping: $ping" if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then bestping=$ping HOST=$pinghost @@ -32,11 +38,12 @@ done [ -z "$HOST" ] && HOST="https://speed.hetzner.de/10GB.bin" -echo "Best server is $HOST, running test:" +[ "$FASTTEST" ] || echo "Best server is $HOST, running test:" trap : HUP INT TERM if [ -z "$INTERFACE" ]; then curl -4 -o /dev/null $HOST || echo else + : /etc/init.d/sqm stop $INTERFACE domain=$(echo $HOST | awk -F/ '{print $3}') hostip=$(dig +nocmd +noall +answer A $domain | grep -v CNAME | awk '{print $5}' | tr '\n' ' ') if [ -n "$(ipset list 2>/dev/null | grep ss_rules)" ]; then @@ -44,10 +51,16 @@ else ipset add ss_rules_dst_bypass_all $ip done fi - curl -4 -o /dev/null --interface $INTERFACE $HOST || echo + if [ "$FASTTEST" ]; then + avg_speed=$(curl -4 --max-time 10 -o /dev/null -qfsS -w '%{speed_download}' --interface $INTERFACE $HOST 2>/dev/null) + echo "$avg_speed" + else + curl -4 --max-time 4 -o /dev/null --interface $INTERFACE $HOST || echo + fi if [ -n "$(ipset list 2>/dev/null | grep ss_rules)" ]; then for ip in $hostip; do ipset del ss_rules_dst_bypass_all $ip done fi + : /etc/init.d/sqm start $INTERFACE fi diff --git a/openmptcprouter/files/bin/omr-test-speed-server b/openmptcprouter/files/bin/omr-test-speed-server index df61352ec..a937a6763 100755 --- a/openmptcprouter/files/bin/omr-test-speed-server +++ b/openmptcprouter/files/bin/omr-test-speed-server @@ -1,6 +1,10 @@ #!/bin/sh SERVER=$1 INTERFACE=$2 +[ "$3" = "upload" ] && UPLOAD=$3 +[ "$3" = "fasttest" ] && FASTTEST=$3 +[ "$4" = "upload" ] && UPLOAD=$4 +[ "$4" = "fasttest" ] && FASTTEST=$4 [ -z "$SERVER" ] && SERVER="vps" KEY=$(uci -q get openmptcprouter.$SERVER.token) HOST=$(uci -q get openmptcprouter.$SERVER.ip | awk '{print $1}') @@ -8,19 +12,37 @@ PORT=$(uci -q get openmptcprouter.$SERVER.port) MP=false if [ -n "$KEY" ] && [ -n "$HOST" ] && [ -n "$PORT" ]; then trap : HUP INT TERM - echo "Download test via server ${SERVER}:" + [ -z "$FASTTEST" ] && echo "Disable SQM bandwidth limit on $INTERFACE" + : /etc/init.d/sqm stop $INTERFACE 2>&1 >/dev/null + [ -z "$FASTTEST" ] && echo "Download test via server ${SERVER}:" if [ -n "$INTERFACE" ]; then - if [ "$(multipath ${INTERFACE} | grep default)" ]; then - MP=true - /etc/init.d/omr-tracker stop 2>&1 >/dev/null - multipath ${INTERFACE} off - fi - curl -k -o /dev/null --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo - if [ $MP ]; then - multipath ${INTERFACE} on - /etc/init.d/omr-tracker start & 2>&1 >/dev/null + #if [ "$(multipath ${INTERFACE} | grep default)" ]; then + # MP=true + # /etc/init.d/omr-tracker stop 2>&1 >/dev/null + # multipath ${INTERFACE} off + #fi + if [ -n "$FASTTEST" ]; then + if [ -n "$UPLOAD" ]; then + avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_upload}' -X POST -d @/boot/vmlinuz -d @/boot/vmlinuz --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest 2>/dev/null) + echo -n "$avg_speed" + else + avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_download}' --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest 2>/dev/null) + echo -n "$avg_speed" + fi + else + if [ -n "$UPLOAD" ]; then + curl -k -o /dev/null -X POST -d @/boot/vmlinuz -d @/boot/vmlinuz --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo + else + curl -k -o /dev/null --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo + fi fi + #if [ $MP ]; then + # multipath ${INTERFACE} on + # /etc/init.d/omr-tracker start & 2>&1 >/dev/null + #fi else curl -k -o /dev/null -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo fi + [ -z "$FASTTEST" ] && echo "Restart SQM on $INTERFACE" + : /etc/init.d/sqm start $INTERFACE 2>&1 >/dev/null fi \ No newline at end of file From 2d3b37888d2069da879507d5b304239a921673a8 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 8 Aug 2023 12:51:50 +0200 Subject: [PATCH 4/6] Add automatic speedtest in wizard --- .../luasrc/controller/openmptcprouter.lua | 7 +++- .../luasrc/view/openmptcprouter/wizard.htm | 18 ++++++-- .../share/omr/post-tracking.d/post-tracking | 42 +++++++++++++++++++ 3 files changed, 62 insertions(+), 5 deletions(-) diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua index 592abcc89..b760b205c 100644 --- a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua +++ b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua @@ -415,6 +415,7 @@ function wizard_add() local downloadspeed = luci.http.formvalue("cbid.sqm.%s.download" % intf) or "0" local uploadspeed = luci.http.formvalue("cbid.sqm.%s.upload" % intf) or "0" + local testspeed = luci.http.formvalue("cbid.sqm.%s.testspeed" % intf) or "0" if not ucic:get("qos",intf) ~= "" then ucic:set("qos",intf,"interface") @@ -438,7 +439,7 @@ function wizard_add() ucic:set("sqm",intf,"script","piece_of_cake.qos") ucic:set("sqm",intf,"qdisc_advanced","0") ucic:set("sqm",intf,"linklayer","atm") - ucic:set("sqm",intf,"overhead","40") + ucic:set("sqm",intf,"overhead","44") ucic:set("sqm",intf,"enabled","0") ucic:set("sqm",intf,"debug_logging","0") ucic:set("sqm",intf,"verbosity","5") @@ -454,6 +455,10 @@ function wizard_add() ucic:set("sqm",intf,"qdisc","cake") ucic:set("sqm",intf,"script","piece_of_cake.qos") end + ucic:set("openmptcprouter",intf,"testspeed",testspeed) + if testspeed == "1" then + ucic:set("openmptcprouter",intf,"testspeed_lc") + end if downloadspeed ~= "0" and downloadspeed ~= "" then if sqmautorate == "1" and (ucic:get("network",intf,"downloadspeed") ~= downloadspeed or ucic:get("sqm",intf,"max_download") == "" or ucic:get("sqm",intf,"download") == "0") then ucic:set("sqm",intf,"download",math.ceil(downloadspeed*65/100)) diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm index 6b005fe5b..159c22fc5 100644 --- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm +++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm @@ -272,7 +272,7 @@ local method=uci:get("openmptcprouter","settings","encryption") if method == nil and ut.trim(sys.exec("cat /proc/cpuinfo | grep aes")) ~= "" then method="aes-256-gcm" - else + elseif method == nil then method="chacha20" end %> @@ -993,12 +993,22 @@ end %>
+ +
+ checked<% end %> /> +
+
+ <%:Run an automatic speedtest to calculate max speed.%> +
+
+
+

- <%:Used by Glorytun UDP and SQM/QoS if enabled. 0 to use default value.%> + <%:Used by Glorytun UDP and SQM/QoS if enabled.%>
-
+

- <%:Used by Glorytun UDP and SQM/QoS if enabled. 0 to use default value.%> + <%:Used by Glorytun UDP and SQM/QoS if enabled.%>