mwan3: add back support for iputils ping
authorAaron Goodman <aaronjg@stanford.edu>
Sun, 11 Oct 2020 22:43:56 +0000 (18:43 -0400)
committerAaron Goodman <aaronjg@stanford.edu>
Fri, 16 Oct 2020 13:55:40 +0000 (09:55 -0400)
With the new wrapper code, we can override the broken binding behavior of
iputils ping v20101006.

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
net/mwan3/files/usr/sbin/mwan3track

index 288fcd35e235416e6208aa5b6a073632172a17ba..8334209fe92bff3303d3c7b10d428146546edb5d 100755 (executable)
@@ -6,7 +6,6 @@
 
 INTERFACE=""
 DEVICE=""
-PING="/bin/ping"
 
 IFDOWN_EVENT=0
 IFUP_EVENT=0
@@ -47,10 +46,19 @@ if_up() {
 validate_track_method() {
        case "$1" in
                ping)
-                       [ -x "$PING" ] || {
-                               LOG warn "Missing ping. Please enable ping util and recompile busybox."
+                       if [ -x "/usr/bin/ping" ] && [ "$(/usr/bin/ping -V | grep -o '[0-9]*$')" -gt 20150519 ]; then
+                               # -4 option added in iputils c3e68ac6
+                               PING="/usr/bin/ping -${FAMILY#ipv}"
+                       elif [ "$FAMILY" = "ipv6" ] && [ -x "/usr/bin/ping6" ]; then
+                               PING="/usr/bin/ping6"
+                       elif [ "$FAMILY" = "ipv4" ] && [ -x "/usr/bin/ping" ]; then
+                               PING="/usr/bin/ping"
+                       elif [ -x "/bin/ping" ]; then
+                               PING="/bin/ping -${FAMILY#ipv}"
+                       else
+                               LOG warn "Missing ping. Please enable BUSYBOX_DEFAULT_PING and recompile busybox or install iputils-ping package."
                                return 1
-                       }
+                       fi
                        ;;
                arping)
                        command -v arping 1>/dev/null 2>&1 || {
@@ -218,12 +226,12 @@ main() {
                                case "$track_method" in
                                        ping)
                                                if [ $check_quality -eq 0 ]; then
-                                                       WRAP $PING -${FAMILY#ipv} -c $count -W $timeout -s $size -t $max_ttl -q $track_ip &> /dev/null &
+                                                       WRAP $PING -c $count -W $timeout -s $size -t $max_ttl -q $track_ip &> /dev/null &
                                                        TRACK_PID=$!
                                                        wait $TRACK_PID
                                                        result=$?
                                                else
-                                                       WRAP $PING -${family#ipv} -c $count -W $timeout -s $size -t $max_ttl -q $track_ip 2>/dev/null > $TRACK_OUTPUT &
+                                                       WRAP $PING -c $count -W $timeout -s $size -t $max_ttl -q $track_ip 2>/dev/null > $TRACK_OUTPUT &
                                                        TRACK_PID=$!
                                                        wait $TRACK_PID
                                                        ping_status=$?