diff --git a/net/mwan3/Makefile b/net/mwan3/Makefile index 5387cd9df5..b75b71b16d 100644 --- a/net/mwan3/Makefile +++ b/net/mwan3/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mwan3 -PKG_VERSION:=2.0.1 +PKG_VERSION:=2.0.2 PKG_RELEASE:=1 PKG_MAINTAINER:=Florian Eckert PKG_LICENSE:=GPLv2 diff --git a/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 b/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 index 0e4c8ee388..1e9599e958 100644 --- a/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 +++ b/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 @@ -47,13 +47,13 @@ case "$ACTION" in mwan3_create_iface_rules $INTERFACE $DEVICE mwan3_create_iface_iptables $INTERFACE $DEVICE mwan3_create_iface_route $INTERFACE $DEVICE + mwan3_set_iface_hotplug_state $INTERFACE "online" mwan3_track $INTERFACE $DEVICE mwan3_set_policies_iptables mwan3_set_user_rules ;; ifdown) - mwan3_delete_iface_rules $INTERFACE - mwan3_delete_iface_route $INTERFACE + mwan3_set_iface_hotplug_state $INTERFACE "offline" mwan3_delete_iface_ipset_entries $INTERFACE mwan3_set_policies_iptables mwan3_set_user_rules diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh index 2bba6f9a32..f7baccd3e1 100644 --- a/net/mwan3/files/lib/mwan3/mwan3.sh +++ b/net/mwan3/files/lib/mwan3/mwan3.sh @@ -7,6 +7,10 @@ IPT4="/usr/sbin/iptables -t mangle -w" IPT6="/usr/sbin/ip6tables -t mangle -w" LOG="/usr/bin/logger -t mwan3 -p" +MWAN3_STATUS_DIR="/var/run/mwan3" + +[ -d $MWAN3_STATUS_DIR ] || mkdir -p $MWAN3_STATUS_DIR/iface_state + mwan3_lock() { lock /var/run/mwan3.lock } @@ -415,7 +419,7 @@ mwan3_set_policy() if [ "$family" == "ipv4" ]; then - if [ -n "$($IP4 route list table $id)" ]; then + if [ "$(mwan3_get_iface_hotplug_state $iface)" = "online" ]; then if [ "$metric" -lt "$lowest_metric_v4" ]; then total_weight_v4=$weight @@ -448,7 +452,7 @@ mwan3_set_policy() if [ "$family" == "ipv6" ]; then - if [ -n "$($IP6 route list table $id)" ]; then + if [ "$(mwan3_get_iface_hotplug_state $iface)" = "online" ]; then if [ "$metric" -lt "$lowest_metric_v6" ]; then total_weight_v6=$weight @@ -679,6 +683,19 @@ mwan3_set_user_rules() config_foreach mwan3_set_user_iptables_rule rule } +mwan3_set_iface_hotplug_state() { + local iface=$1 + local state=$2 + + echo -n $state > $MWAN3_STATUS_DIR/iface_state/$iface +} + +mwan3_get_iface_hotplug_state() { + local iface=$1 + + cat $MWAN3_STATUS_DIR/iface_state/$iface 2>/dev/null || echo "unknown" +} + mwan3_report_iface_status() { local device result track_ips tracking IP IPT @@ -700,16 +717,14 @@ mwan3_report_iface_status() if [ -z "$id" -o -z "$device" ]; then result="unknown" - elif [ -n "$($IP rule | awk '$1 == "'$(($id+1000)):'"')"i -a -n "$($IP rule | awk '$1 == "'$(($id+2000)):'"')" -a -n "$($IPT -S mwan3_iface_in_$1 2> /dev/null)" -a -n "$($IPT -S mwan3_iface_out_$1 2> /dev/null)" -a -n "$($IP route list table $id default dev $device 2> /dev/null)" ]; then - result="online" + elif [ -n "$($IP rule | awk '$1 == "'$(($id+1000)):'"')" -a -n "$($IP rule | awk '$1 == "'$(($id+2000)):'"')" -a -n "$($IPT -S mwan3_iface_in_$1 2> /dev/null)" -a -n "$($IPT -S mwan3_iface_out_$1 2> /dev/null)" -a -n "$($IP route list table $id default dev $device 2> /dev/null)" ]; then + result="$(mwan3_get_iface_hotplug_state $1)" elif [ -n "$($IP rule | awk '$1 == "'$(($id+1000)):'"')" -o -n "$($IP rule | awk '$1 == "'$(($id+2000)):'"')" -o -n "$($IPT -S mwan3_iface_in_$1 2> /dev/null)" -o -n "$($IPT -S mwan3_iface_out_$1 2> /dev/null)" -o -n "$($IP route list table $id default dev $device 2> /dev/null)" ]; then result="error" + elif [ "$enabled" == "1" ]; then + result="offline" else - if [ "$enabled" == "1" ]; then - result="offline" - else - result="disabled" - fi + result="disabled" fi mwan3_list_track_ips() diff --git a/net/mwan3/files/usr/sbin/mwan3 b/net/mwan3/files/usr/sbin/mwan3 index b3285b6f66..3355a0f07a 100755 --- a/net/mwan3/files/usr/sbin/mwan3 +++ b/net/mwan3/files/usr/sbin/mwan3 @@ -46,7 +46,6 @@ ifdown() kill $(cat /var/run/mwan3track-$1.pid) rm /var/run/mwan3track-$1.pid fi - mwan3_delete_iface_iptables $1 } ifup() @@ -166,6 +165,7 @@ stop() done mwan3_lock_clean + rm -rf $MWAN3_STATUS_DIR } restart() {