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 <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert 2022-11-28 10:13:25 +01:00
parent f3054a90ea
commit 1f6bd672fe

View file

@ -351,34 +351,32 @@ main() {
if [ $score -lt $up ]; then if [ $score -lt $up ]; then
score=0 score=0
[ ${keep_failure_interval} -eq 1 ] && sleep_time=$failure_interval [ ${keep_failure_interval} -eq 1 ] && sleep_time=$failure_interval
else elif [ $score -eq $up ]; then
disconnecting
sleep_time=$failure_interval
disconnected
elif [ $score -gt $up ]; then
disconnecting disconnecting
sleep_time=$failure_interval sleep_time=$failure_interval
fi fi
if [ $score -eq $up ]; then
disconnected
score=0
fi
else else
if [ $score -lt $((down+up)) ] && [ $lost -gt 0 ]; then if [ $score -lt $((down+up)) ] && [ $lost -gt 0 ]; then
connecting
LOG info "Lost $((lost*count)) ping(s) on interface $INTERFACE ($DEVICE). Current score: $score" LOG info "Lost $((lost*count)) ping(s) on interface $INTERFACE ($DEVICE). Current score: $score"
fi fi
let score++ let score++
lost=0 lost=0
if [ $score -gt $up ]; then if [ $score -lt $up ]; then
echo "online" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/STATUS connecting
score=$((down+up)) sleep_time=$recovery_interval
elif [ $score -le $up ]; then elif [ $score -eq $up ]; then
connecting connecting
sleep_time=$recovery_interval sleep_time=$recovery_interval
fi
if [ $score -eq $up ]; then
connected connected
elif [ $score -gt $up ]; then
echo "online" > $MWAN3TRACK_STATUS_DIR/$INTERFACE/STATUS
score=$((down+up))
fi fi
fi fi