net/mwan3: add ttl check
authorFlorian Eckert <fe@dev.tdt.de>
Tue, 8 May 2018 11:52:21 +0000 (13:52 +0200)
committerFlorian Eckert <fe@dev.tdt.de>
Mon, 24 Sep 2018 08:20:35 +0000 (10:20 +0200)
Add the additional optional ttl check to test the connection.

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

index 274a024cc833d5d5a935b94433d3ceb099ca3b8d..923bd7bfaf2c4696faf48f6020a3678cd1dca49e 100755 (executable)
@@ -55,6 +55,7 @@ main() {
        local recovery_interval down up size
        local keep_failure_interval check_quality failure_latency
        local recovery_latency failure_loss recovery_loss
+       local max_ttl
 
        [ -z "$5" ] && echo "Error: should not be started manually" && exit 0
 
@@ -84,6 +85,7 @@ main() {
        config_get down $1 down 5
        config_get up $1 up 5
        config_get size $1 size 56
+       config_get max_ttl $1 max_ttl 60
        config_get failure_interval $1 failure_interval $interval
        config_get_bool keep_failure_interval $1 keep_failure_interval 0
        config_get recovery_interval $1 recovery_interval $interval
@@ -120,10 +122,10 @@ main() {
                                case "$track_method" in
                                        ping)
                                                if [ $check_quality -eq 0 ]; then
-                                                       ping -I $DEVICE -c $count -W $timeout -s $size -q $track_ip &> /dev/null
+                                                       ping -I $DEVICE -c $count -W $timeout -s $size -t $max_ttl -q $track_ip &> /dev/null
                                                        result=$?
                                                else
-                                                       ping_result="$(ping -I $DEVICE -c $count -W $timeout -s $size -q $track_ip | tail -2)"
+                                                       ping_result="$(ping -I $DEVICE -c $count -W $timeout -s $size -t $max_ttl -q $track_ip | tail -2)"
                                                        loss="$(echo "$ping_result" | grep "packet loss" |  cut -d "," -f3 | awk '{print $1}' | sed -e 's/%//')"
                                                        if [ "$loss" -eq 100 ]; then
                                                                latency=999999