diff options
author | Aaron Goodman <aaronjg@stanford.edu> | 2020-11-15 11:35:28 -0500 |
---|---|---|
committer | Aaron Goodman <aaronjg@stanford.edu> | 2020-11-16 11:23:10 -0500 |
commit | 1bfb1a66cd3b5a09ac4abc7da5e3508a772318ac (patch) | |
tree | e416b25459f3465cceaf958987820c24d2d4e298 /net/mwan3 | |
parent | f014a7f5420aaf706c046394f51200faad7fbd88 (diff) |
mwan3: support latest iputils ping
iputils upstream changed build params with version s20200821
Latest OpenWRT iputils ping now appears to report the openwrt
version tag, rather than iputils date tag
This commit sends a test ping to localhost to evaluate the
capabilities of iputils ping.
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
Diffstat (limited to 'net/mwan3')
-rwxr-xr-x | net/mwan3/files/usr/sbin/mwan3track | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/net/mwan3/files/usr/sbin/mwan3track b/net/mwan3/files/usr/sbin/mwan3track index d4a5f44ab..bd8954c07 100755 --- a/net/mwan3/files/usr/sbin/mwan3track +++ b/net/mwan3/files/usr/sbin/mwan3track @@ -40,19 +40,35 @@ if_up() { stop_subprocs } +ping_test_host() { + if [ "$FAMILY" = "ipv6" ]; then + echo "::1" + else + echo "127.0.0.1" + fi +} + +get_ping_command() { + if [ -x "/usr/bin/ping" ] && /usr/bin/ping -${FAMILY#ipv} -c1 -q $(ping_test_host) &>/dev/null; then + # -4 option added in iputils c3e68ac6 so need to check if we can use it + # or if we must use ping and ping6 + echo "/usr/bin/ping -${FAMILY#ipv}" + elif [ "$FAMILY" = "ipv6" ] && [ -x "/usr/bin/ping6" ]; then + echo "/usr/bin/ping6" + elif [ "$FAMILY" = "ipv4" ] && [ -x "/usr/bin/ping" ]; then + echo "/usr/bin/ping" + elif [ -x "/bin/ping" ]; then + echo "/bin/ping -${FAMILY#ipv}" + else + return 1 + fi +} + validate_track_method() { case "$1" in ping) - 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 + PING=$(get_ping_command) + if [ $? -ne 0 ]; then LOG warn "Missing ping. Please enable BUSYBOX_DEFAULT_PING and recompile busybox or install iputils-ping package." return 1 fi |