diff options
author | Florian Eckert <fe@dev.tdt.de> | 2021-09-08 11:33:55 +0200 |
---|---|---|
committer | Florian Eckert <fe@dev.tdt.de> | 2022-10-17 15:17:31 +0200 |
commit | 997c0842ca8b05de83a1ecd3160ecd18fa3d8aee (patch) | |
tree | 3e192c3dcf69bc9c75bbee119b05ed46995423aa | |
parent | a6606bed17bbddb7ae10405f6b0358fdda26fd17 (diff) |
mwan3: only send disconnected event if interface was connected before
Up to now on every interface down event a mwan3 disconnected event was
send. This is wrong because if the interface was never connected, then a
disconnected event should not get generated. This commit fixes this bug.
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
-rwxr-xr-x | net/mwan3/files/usr/sbin/mwan3track | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/net/mwan3/files/usr/sbin/mwan3track b/net/mwan3/files/usr/sbin/mwan3track index 2c535d59f..89654f86b 100755 --- a/net/mwan3/files/usr/sbin/mwan3track +++ b/net/mwan3/files/usr/sbin/mwan3track @@ -105,14 +105,22 @@ validate_wrap() { } disconnected() { + local status="$(cat ${MWAN3TRACK_STATUS_DIR}/${INTERFACE}/STATUS)" + STATUS='offline' echo "offline" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/STATUS get_uptime > $MWAN3TRACK_STATUS_DIR/$INTERFACE/OFFLINE echo "0" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/ONLINE score=0 [ "$1" = 1 ] && return - LOG notice "Interface $INTERFACE ($DEVICE) is offline" - env -i ACTION="disconnected" INTERFACE="$INTERFACE" DEVICE="$DEVICE" /sbin/hotplug-call iface + + # Only execute disconnectd action if status was online or disconnecting + if [ "$status" = "online" ] || [ "$status" = "disconnecting" ]; then + LOG notice "Interface $INTERFACE ($DEVICE) is offline" + env -i ACTION="disconnected" INTERFACE="$INTERFACE" DEVICE="$DEVICE" /sbin/hotplug-call iface + else + LOG notice "Skip disconnected event for $INTERFACE ($DEVICE)" + fi } connected() { @@ -391,8 +399,8 @@ main() { if [ "${IFDOWN_EVENT}" -eq 1 ]; then LOG debug "Register ifdown event on interface ${INTERFACE} (${DEVICE})" - disabled disconnected + disabled IFDOWN_EVENT=0 fi if [ "${IFUP_EVENT}" -eq 1 ]; then |