From: Florian Eckert Date: Mon, 28 Nov 2022 09:13:25 +0000 (+0100) Subject: mwan3: refactoring mwan3track action handling X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=1f6bd672fecd1ffc9f6b1fea152edc62bcdca026;p=openwrt-packages.git mwan3: refactoring mwan3track action handling Refactoring the score handling, so that only one action could take place during run. The behaviour should be more comprehensible, since several score actions are not processed at the same time. Signed-off-by: Florian Eckert --- diff --git a/net/mwan3/files/usr/sbin/mwan3track b/net/mwan3/files/usr/sbin/mwan3track index 89654f86b..c1a455b2e 100755 --- a/net/mwan3/files/usr/sbin/mwan3track +++ b/net/mwan3/files/usr/sbin/mwan3track @@ -351,34 +351,32 @@ main() { if [ $score -lt $up ]; then score=0 [ ${keep_failure_interval} -eq 1 ] && sleep_time=$failure_interval - else + elif [ $score -eq $up ]; then disconnecting sleep_time=$failure_interval - fi - - if [ $score -eq $up ]; then disconnected - score=0 + elif [ $score -gt $up ]; then + disconnecting + sleep_time=$failure_interval 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 let score++ lost=0 - if [ $score -gt $up ]; then - echo "online" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/STATUS - score=$((down+up)) - elif [ $score -le $up ]; then + if [ $score -lt $up ]; then + connecting + sleep_time=$recovery_interval + elif [ $score -eq $up ]; then connecting sleep_time=$recovery_interval - fi - - if [ $score -eq $up ]; then connected + elif [ $score -gt $up ]; then + echo "online" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/STATUS + score=$((down+up)) fi fi