From 1990a90702515aead6412749fb6aafb21136112d Mon Sep 17 00:00:00 2001 From: Aaron Goodman Date: Sun, 11 Oct 2020 18:43:56 -0400 Subject: [PATCH] mwan3: add back support for iputils ping With the new wrapper code, we can override the broken binding behavior of iputils ping v20101006. Signed-off-by: Aaron Goodman --- net/mwan3/files/usr/sbin/mwan3track | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/net/mwan3/files/usr/sbin/mwan3track b/net/mwan3/files/usr/sbin/mwan3track index 288fcd35e2..8334209fe9 100755 --- a/net/mwan3/files/usr/sbin/mwan3track +++ b/net/mwan3/files/usr/sbin/mwan3track @@ -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=$?