mwan3: add connecting and disconnecting event to mwan3track
authorFlorian Eckert <fe@dev.tdt.de>
Tue, 2 Mar 2021 15:04:49 +0000 (16:04 +0100)
committerFlorian Eckert <fe@dev.tdt.de>
Tue, 16 Mar 2021 08:24:36 +0000 (09:24 +0100)
If the interface goes into failure state (is disconnecting)
then with this change one hotplug.d event is generated.

The same is true for the recovery state (is connecting), when the interface
comes back from a failure state.

In both cases, a hotplug.d event for the iface is triggered. Once
with the $ACTION=disconnecting and once for the $ACTION=connecting.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
net/mwan3/Makefile
net/mwan3/files/usr/sbin/mwan3track

index c8f551df2fba84f60968b9d6da920a81eb76147e..6909505f7f8dabec4c10f2af37e7940f47359cca 100644 (file)
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=mwan3
-PKG_VERSION:=2.10.7
+PKG_VERSION:=2.10.8
 PKG_RELEASE:=1
 PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>, \
                Aaron Goodman <aaronjg@alumni.stanford.edu>
index fd81f68c3b68ff2253ce29bb163bd2dc8dfb15ce..2c535d59ffe2a00975da1c805ac7b8d97cb525df 100755 (executable)
@@ -128,6 +128,24 @@ connected() {
        env -i FIRSTCONNECT=$1 ACTION="connected" INTERFACE="$INTERFACE" DEVICE="$DEVICE" /sbin/hotplug-call iface
 }
 
+disconnecting() {
+       if [ "$STATUS" != "disconnecting" ] ; then
+               STATUS="disconnecting"
+               echo "disconnecting" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/STATUS
+               LOG notice "Interface $INTERFACE ($DEVICE) is disconnecting"
+               env -i ACTION="disconnecting" INTERFACE="$INTERFACE" DEVICE="$DEVICE" /sbin/hotplug-call iface
+       fi
+}
+
+connecting() {
+       if [ "$STATUS" != "connecting" ] ; then
+               STATUS="connecting"
+               echo "connecting" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/STATUS
+               LOG notice "Interface $INTERFACE ($DEVICE) is connecting"
+               env -i ACTION="connecting" INTERFACE="$INTERFACE" DEVICE="$DEVICE" /sbin/hotplug-call iface
+       fi
+}
+
 disabled() {
        STATUS='disabled'
        echo "disabled" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/STATUS
@@ -326,6 +344,7 @@ main() {
                                score=0
                                [ ${keep_failure_interval} -eq 1 ] && sleep_time=$failure_interval
                        else
+                               disconnecting
                                sleep_time=$failure_interval
                        fi
 
@@ -335,6 +354,7 @@ main() {
                        fi
                else
                        if [ $score -lt $((down+up)) ] && [ $lost -gt 0 ]; then
+                               connecting
                                LOG info "Lost $((lost*count)) ping(s) on interface $INTERFACE ($DEVICE). Current score: $score"
                        fi
 
@@ -345,6 +365,7 @@ main() {
                                echo "online" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/STATUS
                                score=$((down+up))
                        elif [ $score -le $up ]; then
+                               connecting
                                sleep_time=$recovery_interval
                        fi