diff --git a/net/mwan3/Makefile b/net/mwan3/Makefile index 4850bfae43..99990e4cca 100644 --- a/net/mwan3/Makefile +++ b/net/mwan3/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mwan3 -PKG_VERSION:=2.10.0 +PKG_VERSION:=2.10.1 PKG_RELEASE:=1 PKG_MAINTAINER:=Florian Eckert PKG_LICENSE:=GPL-2.0 diff --git a/net/mwan3/files/etc/init.d/mwan3 b/net/mwan3/files/etc/init.d/mwan3 index 595fabf777..b7cf91eb17 100755 --- a/net/mwan3/files/etc/init.d/mwan3 +++ b/net/mwan3/files/etc/init.d/mwan3 @@ -111,6 +111,11 @@ stop_service() { mwan3_unlock "command" "mwan3" } +reload_service() { + stop + start +} + service_triggers() { procd_add_reload_trigger 'mwan3' } diff --git a/net/mwan3/files/lib/mwan3/common.sh b/net/mwan3/files/lib/mwan3/common.sh index daa4b2abcc..5c9b2a805e 100644 --- a/net/mwan3/files/lib/mwan3/common.sh +++ b/net/mwan3/files/lib/mwan3/common.sh @@ -23,6 +23,9 @@ MMX_UNREACHABLE="" MM_UNREACHABLE="" MAX_SLEEP=$(((1<<31)-1)) +command -v ip6tables > /dev/null +NO_IPV6=$? + LOG() { local facility=$1; shift diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh index 2a689c0c81..e6e43ebe85 100644 --- a/net/mwan3/files/lib/mwan3/mwan3.sh +++ b/net/mwan3/files/lib/mwan3/mwan3.sh @@ -24,9 +24,6 @@ IPv4_REGEX="((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[0 DEFAULT_LOWEST_METRIC=256 -command -v ip6tables > /dev/null -NO_IPV6=$? - mwan3_push_update() { # helper function to build an update string to pass on to diff --git a/net/mwan3/files/usr/libexec/rpcd/mwan3 b/net/mwan3/files/usr/libexec/rpcd/mwan3 index 76f557e9fe..a97b33d5cf 100755 --- a/net/mwan3/files/usr/libexec/rpcd/mwan3 +++ b/net/mwan3/files/usr/libexec/rpcd/mwan3 @@ -5,8 +5,6 @@ . /usr/share/libubox/jshn.sh . /lib/mwan3/common.sh -MWAN3TRACK_STATUS_DIR="/var/run/mwan3track" - IPS="ipset" IPT4="iptables -t mangle -w" IPT6="ip6tables -t mangle -w" @@ -22,6 +20,7 @@ report_connected_v4() { } report_connected_v6() { + [ $NO_IPV6 -ne 0 ] && return local address if [ -n "$($IPT6 -S mwan3_connected 2> /dev/null)" ]; then @@ -60,6 +59,7 @@ report_policies_v4() { } report_policies_v6() { + [ $NO_IPV6 -ne 0 ] && return local policy for policy in $($IPT6 -S | awk '{print $2}' | grep mwan3_policy_ | sort -u); do diff --git a/net/mwan3/files/usr/sbin/mwan3 b/net/mwan3/files/usr/sbin/mwan3 index 0251607a07..45776bdfc3 100755 --- a/net/mwan3/files/usr/sbin/mwan3 +++ b/net/mwan3/files/usr/sbin/mwan3 @@ -123,7 +123,7 @@ restart() { /etc/init.d/mwan3 start } -wrap() { +use() { # Run a command with the device, src_ip and fwmark set to avoid processing by mwan3 # firewall rules @@ -132,7 +132,7 @@ wrap() { config_load mwan3 interface=$1 ; shift - [ -z "$*" ] && echo "no command specified for mwan3 wrap" && return + [ -z "$*" ] && echo "no command specified for mwan3 use" && return network_get_device device $interface [ -z "$device" ] && echo "could not find device for $interface" && return diff --git a/net/mwan3/files/usr/sbin/mwan3rtmon b/net/mwan3/files/usr/sbin/mwan3rtmon index ee470837e4..569b4d1729 100755 --- a/net/mwan3/files/usr/sbin/mwan3rtmon +++ b/net/mwan3/files/usr/sbin/mwan3rtmon @@ -74,7 +74,7 @@ mwan3_rtmon_route_handle() route_line=${1##"Deleted "} route_family=$2 - config_get_boolean source_routing globals source_routing 0 + config_get_bool source_routing globals source_routing 0 [ $source_routing -eq 0 ] && unset source_routing if [ "$route_line" = "$1" ]; then @@ -107,22 +107,22 @@ mwan3_rtmon_route_handle() local iface=$1 tbl=$($IP route list table $tid 2>/dev/null)$'\n' - if [ "$(cat /var/run/mwan3track/$iface/STATUS)" != "online" ]; then - LOG debug "interface $iface is offline - skipping $route_line"; + if [ -n "$iface" ] && [ "$(mwan3_get_mwan3track_status $iface)" != "active" ]; then + LOG debug "interface $iface is disabled - skipping '$route_line'"; return fi # check that action needs to be performed. May not need to take action if we # got a delete event, but table was already flushed if [ $action = "del" ] && [ -n "${tbl##*$route_line$'\n'*}" ]; then - LOG debug "skipping already deleted route table $tid - skipping $route_line" + LOG debug "skipping already deleted route table $tid - skipping '$route_line'" return fi network_get_device device "$iface" - LOG debug "adjusting route $device: $IP route $action table $tid $route_line" + LOG debug "adjusting route $device: '$IP route $action table $tid $route_line'" $IP route "$action" table $tid $route_line || - LOG warn "failed: $IP route $action table $tid $route_line" + LOG warn "failed: '$IP route $action table $tid $route_line'" } handle_route_cb(){ local iface=$1 @@ -163,9 +163,9 @@ main() sh -c "echo \$\$; exec $IP monitor route" | { read -r monitor_pid trap_with_arg func_trap "$monitor_pid" SIGINT SIGTERM SIGKILL - while read -r line; do + while IFS='' read -r line; do [ -z "${line##*table*}" ] && continue - LOG debug "handling route update $family $line" + LOG debug "handling route update $family '$line'" mwan3_lock "service" "mwan3rtmon" mwan3_rtmon_route_handle "$line" "$family" mwan3_unlock "service" "mwan3rtmon" diff --git a/net/mwan3/files/usr/sbin/mwan3track b/net/mwan3/files/usr/sbin/mwan3track index b771e8fced..d97933e09b 100755 --- a/net/mwan3/files/usr/sbin/mwan3track +++ b/net/mwan3/files/usr/sbin/mwan3track @@ -345,8 +345,12 @@ main() { get_uptime > $MWAN3TRACK_STATUS_DIR/$INTERFACE/TIME host_up_count=0 - sleep "${sleep_time}" & - wait + if [ "${IFDOWN_EVENT}" -ne 0 ] && [ "${IFUP_EVENT}" -ne 0 ]; then + sleep "${sleep_time}" & + SLEEP_PID=$! + wait + unset SLEEP_PID + fi if [ "${IFDOWN_EVENT}" -eq 1 ]; then LOG debug "Register ifdown event on interface ${INTERFACE} (${DEVICE})"