From 081d432ea4177b76c068390393bde25df9d1fc8b Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 15 Dec 2023 08:48:11 +0100 Subject: [PATCH 1/4] Add more log --- mptcp/files/etc/hotplug.d/iface/30-mptcp | 1 + mptcp/files/usr/share/omr/post-tracking.d/001-post-tracking | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mptcp/files/etc/hotplug.d/iface/30-mptcp b/mptcp/files/etc/hotplug.d/iface/30-mptcp index 6363894b0..607718dd1 100644 --- a/mptcp/files/etc/hotplug.d/iface/30-mptcp +++ b/mptcp/files/etc/hotplug.d/iface/30-mptcp @@ -10,6 +10,7 @@ if [ "$ACTION" = ifup -o "$ACTION" = ifupdate -o "$ACTION" = iflink ] && [ -z "$ logger -t "mptcp" "Reloading mptcp config due to $ACTION of $INTERFACE ($DEVICE)" /etc/init.d/mptcp reload "$DEVICE" >/dev/null || exit 0 else + logger -t "mptcp" "Set multipath off on $DEVICE ($INTERFACE) due to $ACTION" multipath $DEVICE off 2>&1 >/dev/null fi diff --git a/mptcp/files/usr/share/omr/post-tracking.d/001-post-tracking b/mptcp/files/usr/share/omr/post-tracking.d/001-post-tracking index 737415ae9..a6e347037 100755 --- a/mptcp/files/usr/share/omr/post-tracking.d/001-post-tracking +++ b/mptcp/files/usr/share/omr/post-tracking.d/001-post-tracking @@ -1246,7 +1246,7 @@ fi _log "Reload MPTCP config for $OMR_TRACKER_DEVICE" /etc/init.d/mptcp reload "$OMR_TRACKER_DEVICE" fi - _log "Multipath $OMR_TRACKER_DEVICE switched to $multipath_config (from $multipath_status)" + _log "Multipath $OMR_TRACKER_DEVICE ($OMR_TRACKER_INTERFACE) switched to $multipath_config (from $multipath_status)" multipath "$OMR_TRACKER_DEVICE" "$multipath_config" fi } From e374f7cb2e582965cde792b4366d8bb825852e40 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 15 Dec 2023 08:58:10 +0100 Subject: [PATCH 2/4] More log for MPTCP --- mptcp/files/etc/init.d/mptcp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mptcp/files/etc/init.d/mptcp b/mptcp/files/etc/init.d/mptcp index d5dcf5f90..d3f6e1072 100755 --- a/mptcp/files/etc/init.d/mptcp +++ b/mptcp/files/etc/init.d/mptcp @@ -206,8 +206,9 @@ interface_multipath_settings() { #echo "îface: $iface" if [ "$(uci -q get openmptcprouter.settings.force_multipath)" != "0" ]; then + _logger -t "MPTCP" "Set $iface to $mode" if [ "$mode" = "master" ]; then - multipath "$iface" "on" + multipath "$iface" "on" else multipath "$iface" "$mode" fi @@ -428,7 +429,8 @@ set_multipath() { exist=1 fi done - [ "$exist" = "0" ] && { + [ "$exist" = "0" ] && [ -z "$(multipath $iface | grep deactivated)" ] && { + logger -t "MPTCP" "Disabling MPTCP on interface $iface not found in enabled multipath list" multipath $iface off } done From ced4a76faa1a8d3170b1a591d0462f489fae1907 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 15 Dec 2023 19:30:31 +0100 Subject: [PATCH 3/4] Add test count as setting for OMR-Tracker --- .../luasrc/model/cbi/omr-tracker.lua | 14 +++++++++++++- omr-tracker/files/bin/omr-tracker | 15 ++++++++------- omr-tracker/files/etc/config/omr-tracker | 2 +- omr-tracker/files/etc/init.d/omr-tracker | 10 +++++++--- omr-tracker/files/etc/uci-defaults/omr-tracker | 6 ++++++ 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/luci-app-omr-tracker/luasrc/model/cbi/omr-tracker.lua b/luci-app-omr-tracker/luasrc/model/cbi/omr-tracker.lua index d81df88be..0e22a0e94 100644 --- a/luci-app-omr-tracker/luasrc/model/cbi/omr-tracker.lua +++ b/luci-app-omr-tracker/luasrc/model/cbi/omr-tracker.lua @@ -110,12 +110,18 @@ o.default = "1" o.datatype = "range(1, 100)" o.rmempty = false -o = s:option(Value, "tries", translate("Tries")) +o = s:option(Value, "tries", translate("Tries"), translate("How many times repeat test")) o.placeholder = "4" o.default = "4" o.datatype = "range(1, 10)" o.rmempty = false +o = s:option(Value, "count", translate("Count"), translate("How many packets send on each test")) +o.placeholder = "2" +o.default = "2" +o.datatype = "range(1, 100)" +o.rmempty = false + o = s:option(Value, "interval", translate("Retry interval (s)")) o.placeholder = "2" o.default = "2" @@ -191,6 +197,12 @@ o.default = "4" o.datatype = "range(1, 10)" o.rmempty = false +o = s:option(Value, "count", translate("Count"), translate("How many packets send on each test, one wrong make test fail, one wrong make tail fail")) +o.placeholder = "2" +o.default = "2" +o.datatype = "range(1, 100)" +o.rmempty = false + o = s:option(Value, "interval", translate("Retry interval (s)")) o.placeholder = "2" o.default = "2" diff --git a/omr-tracker/files/bin/omr-tracker b/omr-tracker/files/bin/omr-tracker index 81a37258b..75dc32ea2 100755 --- a/omr-tracker/files/bin/omr-tracker +++ b/omr-tracker/files/bin/omr-tracker @@ -148,10 +148,10 @@ _ping() { if [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "3g" ] || [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "qmi" ] || [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "ncm" ]); then ret=$(ping -I "${device}" \ -w "$OMR_TRACKER_TIMEOUT" \ - -c 2 \ + -c "$OMR_TRACKER_COUNT" \ -Q 184 \ "${host}" 2>&1 - ) && echo "$ret" | grep -sq "bytes from" && { + ) && echo "$ret" | grep -sq " 0% packet loss" && { if [ "$localip" = "yes" ]; then OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') _update_rto "$OMR_TRACKER_LATENCY" @@ -161,16 +161,17 @@ _ping() { else ret=$(ping -B -I "${device}" \ -w "$OMR_TRACKER_TIMEOUT" \ - -c 2 \ + -c "$OMR_TRACKER_COUNT" \ -Q 184 \ "${host}" 2>&1 - ) && echo "$ret" | grep -sq "bytes from" && { + ) && echo "$ret" | grep -sq " 0% packet loss" && { if [ "$localip" = "yes" ]; then OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') _update_rto "$OMR_TRACKER_LATENCY" fi return } + #) && echo "$ret" | grep -sq "bytes from" && { fi false } @@ -184,7 +185,7 @@ _httping() { ret=$(httping "${host}" \ -y "${deviceip}" \ -t "$OMR_TRACKER_TIMEOUT" \ - -c 1 2>&1 + -c "$OMR_TRACKER_COUNT" 2>&1 ) && echo "$ret" | grep -sq "1 ok" && { if [ "$localip" = "yes" ]; then OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') @@ -196,7 +197,7 @@ _httping() { ret=$(httping -l "${host}" \ -y "${deviceip}" \ -t "$OMR_TRACKER_TIMEOUT" \ - -c 1 2>&1 + -c "$OMR_TRACKER_COUNT" 2>&1 ) && echo "$ret" | grep -sq "1 ok" && { if [ "$localip" = "yes" ]; then OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') @@ -214,7 +215,7 @@ _dns() { ret=$(dig @"${host}" \ -b "${deviceip}" \ +time="$OMR_TRACKER_TIMEOUT" \ - +tries=1 \ + +tries="$OMR_TRACKER_COUNT" \ one.one.one.one ) && echo "$ret" | grep -sq "1.1.1.1" && { OMR_TRACKER_LATENCY=$(echo "$ret" | awk '/Query time/{print $4}') diff --git a/omr-tracker/files/etc/config/omr-tracker b/omr-tracker/files/etc/config/omr-tracker index a2666586a..c8e484e08 100644 --- a/omr-tracker/files/etc/config/omr-tracker +++ b/omr-tracker/files/etc/config/omr-tracker @@ -18,6 +18,7 @@ config defaults 'defaults' list hosts6 '2001:4860:4860::8888' list hosts6 '2001:4860:4860::8844' option timeout '2' + option count '2' option tries '3' option interval '2' option interval_tries '1' @@ -29,7 +30,6 @@ config defaults 'defaults' config proxy 'proxy' option enabled '1' - list hosts '1.0.0.1' list hosts '212.27.48.10' list hosts '198.27.92.1' list hosts '151.101.129.164' diff --git a/omr-tracker/files/etc/init.d/omr-tracker b/omr-tracker/files/etc/init.d/omr-tracker index 1b7699ea7..76044c99a 100755 --- a/omr-tracker/files/etc/init.d/omr-tracker +++ b/omr-tracker/files/etc/init.d/omr-tracker @@ -16,13 +16,14 @@ . /lib/functions/network.sh _validate_section() { - local tmp_hosts=$hosts tmp_hosts6=$hosts6 tmp_timeout=$timeout tmp_tries=$tries + local tmp_hosts=$hosts tmp_hosts6=$hosts6 tmp_timeout=$timeout tmp_count=$count tmp_tries=$tries local tmp_interval=$interval tmp_interval_tries=$interval_tries tmp_options=$options tmp_type=$type tmp_enabled=$enabled tmp_wait_test=$wait_test tmp_server_http_test=$server_http_test uci_validate_section omr-tracker "$1" "$2" \ 'hosts:list(host)' \ 'hosts6:list(host)' \ 'timeout:uinteger' \ + 'count:uinteger' \ 'tries:uinteger' \ 'interval:uinteger' \ 'interval_tries:uinteger' \ @@ -35,6 +36,7 @@ _validate_section() { [ -z "$hosts" ] && hosts=$tmp_hosts [ -z "$hosts6" ] && hosts6=$tmp_hosts6 [ -z "$timeout" ] && timeout=$tmp_timeout + [ -z "$count" ] && count=$tmp_count [ -z "$tries" ] && tries=$tmp_tries [ -z "$interval" ] && interval=$tmp_interval [ -z "$interval_tries" ] && interval_tries=$tmp_interval_tries @@ -50,7 +52,7 @@ _launch_tracker() { loopback|lan*|if0*) return;; esac [ -z "$1" ] && return - local hosts hosts6 timeout tries interval interval_tries options type enabled wait_test ipv6 proto server_http_test + local hosts hosts6 timeout count tries interval interval_tries options type enabled wait_test ipv6 proto server_http_test _validate_section "defaults" "defaults" _validate_section "interface" "$1" @@ -75,8 +77,9 @@ _launch_tracker() { [ -z "${hosts}" ] && [ "$type" != "none" ] && return ifstatus=$(ifstatus "$1" | jsonfilter -q -e '@["up"]') ifdevice=$(ifstatus "$1" | jsonfilter -q -e '@["device"]') - [ "${ifstatus}" = "false" ] && [ -z "${ifdevice}" ] && return + #[ "${ifstatus}" = "false" ] && [ -z "${ifdevice}" ] && return [ -z "${interval_tries}" ] && interval_tries=1 + [ -z "${count}" ] && count=2 procd_open_instance # shellcheck disable=SC2086 @@ -84,6 +87,7 @@ _launch_tracker() { procd_append_param env "OMR_TRACKER_HOSTS=$hosts" procd_append_param env "OMR_TRACKER_HOSTS6=$hosts6" procd_append_param env "OMR_TRACKER_TIMEOUT=$timeout" + procd_append_param env "OMR_TRACKER_COUNT=$count" procd_append_param env "OMR_TRACKER_TRIES=$tries" procd_append_param env "OMR_TRACKER_INTERVAL=$interval" procd_append_param env "OMR_TRACKER_INTERVAL_TRIES=$interval_tries" diff --git a/omr-tracker/files/etc/uci-defaults/omr-tracker b/omr-tracker/files/etc/uci-defaults/omr-tracker index 7ae77dddf..55d8d4ee6 100755 --- a/omr-tracker/files/etc/uci-defaults/omr-tracker +++ b/omr-tracker/files/etc/uci-defaults/omr-tracker @@ -64,6 +64,12 @@ if [ "$(uci -q get omr-tracker.proxy.hosts | grep '176.103.130.130')" != "" ]; t commit omr-tracker EOF fi +if [ "$(uci -q get omr-tracker.proxy.hosts | grep '1.0.0.1')" != "" ]; then + uci -q batch <<-EOF >/dev/null + del_list omr-tracker.proxy.hosts='1.0.0.1' + commit omr-tracker + EOF +fi if [ "$(uci -q get omr-tracker.proxy.hosts | grep '198.41.212.162')" = "" ]; then uci -q batch <<-EOF >/dev/null From 5d4c0e2d22c49b233691c9843ea3261db63ab03b Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 15 Dec 2023 19:31:07 +0100 Subject: [PATCH 4/4] Fix omr-test-speed-server --- .../files/bin/omr-test-speed-server | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/openmptcprouter/files/bin/omr-test-speed-server b/openmptcprouter/files/bin/omr-test-speed-server index 92f9334b5..39a0a878f 100755 --- a/openmptcprouter/files/bin/omr-test-speed-server +++ b/openmptcprouter/files/bin/omr-test-speed-server @@ -27,8 +27,8 @@ if [ -n "$HOST" ] && [ -n "$PORT" ] && [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]; [ -z "$FASTTEST" ] && echo "No answer to API request..." exit 1 } - KEY="$(echo '$auth' | jsonfilter -q -e '@.access_token')" - [ -n "$KEY" ] && { + KEY=$(echo "$auth" | jsonfilter -q -e '@.access_token') + [ -z "$KEY" ] && { [ -z "$FASTTEST" ] && echo "No token..." exit 1 } @@ -63,17 +63,33 @@ if [ -n "$HOST" ] && [ -n "$PORT" ] && [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]; 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 @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest 2>/dev/null) + if [ "$resolve" != "${HOST}" ] || [ "$valid_ip6" != "ok" ]; then + avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_upload}' -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest 2>/dev/null) + else + avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_upload}' -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://[${HOST}]:${PORT}/speedtest 2>/dev/null) + fi 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) + if [ "$resolve" != "${HOST}" ] || [ "$valid_ip6" != "ok" ]; then + 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) + 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) + fi echo -n "$avg_speed" fi else if [ -n "$UPLOAD" ]; then - curl -k -o /dev/null -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo + if [ "$resolve" != "${HOST}" ] || [ "$valid_ip6" != "ok" ]; then + curl -k -o /dev/null -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo + else + curl -k -o /dev/null -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://[${HOST}]:${PORT}/speedtest || echo + fi else - curl -k -o /dev/null --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo + if [ "$resolve" != "${HOST}" ] || [ "$valid_ip6" != "ok" ]; then + curl -k -o /dev/null --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 fi #if [ $MP ]; then @@ -83,6 +99,10 @@ if [ -n "$HOST" ] && [ -n "$PORT" ] && [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]; [ -z "$FASTTEST" ] && echo "Restart SQM on $INTERFACE" /etc/init.d/sqm start $INTERFACE 2>&1 >/dev/null else - curl -k -o /dev/null -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo + if [ "$resolve" != "${HOST}" ] || [ "$valid_ip6" != "ok" ]; then + curl -k -o /dev/null -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo + else + curl -k -o /dev/null -H "Authorization: Bearer ${KEY}" https://[${HOST}]:${PORT}/speedtest || echo + fi fi fi \ No newline at end of file