diff options
author | Alan Somers <asomers@FreeBSD.org> | 2020-11-26 18:33:04 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2020-11-26 18:33:04 +0000 |
commit | d26245171514e85becdd350ee5574f7c886a5db0 (patch) | |
tree | 188826f6a68bc846d35f61aa1cf658e26bc10e27 /sbin/ping | |
parent | f7af6e5e54ebd1e3d70dd3d9d9660f049c1dbd2b (diff) | |
download | src-d26245171514e85becdd350ee5574f7c886a5db0.tar.gz src-d26245171514e85becdd350ee5574f7c886a5db0.zip |
ping: add a ping6 hard link for backwards compatibility
When invoked as "ping6", ping will now attempt to use ICMPv6 for hostnames
that resolve both IPv4 and IPv6 addresses.
Reviewed by: bz, manu
MFC-With: r368045
Differential Revision: https://reviews.freebsd.org/D27384
Notes
Notes:
svn path=/head/; revision=368078
Diffstat (limited to 'sbin/ping')
-rw-r--r-- | sbin/ping/Makefile | 1 | ||||
-rw-r--r-- | sbin/ping/main.c | 5 | ||||
-rw-r--r-- | sbin/ping/ping.8 | 5 | ||||
-rw-r--r-- | sbin/ping/tests/ping_test.sh | 14 |
4 files changed, 23 insertions, 2 deletions
diff --git a/sbin/ping/Makefile b/sbin/ping/Makefile index 437d2f6b1b5a..c9cc63bbf74d 100644 --- a/sbin/ping/Makefile +++ b/sbin/ping/Makefile @@ -15,6 +15,7 @@ LIBADD= m CFLAGS+= -DINET6 -DKAME_SCOPEID SRCS+= ping6.c LIBADD+= md +LINKS= ${BINDIR}/ping ${BINDIR}/ping6 .endif .if ${MK_DYNAMICROOT} == "no" diff --git a/sbin/ping/main.c b/sbin/ping/main.c index 13891e15da36..96150beec8b7 100644 --- a/sbin/ping/main.c +++ b/sbin/ping/main.c @@ -66,7 +66,10 @@ main(int argc, char *argv[]) struct in6_addr a6; bool ipv6; - ipv6 = false; + if (strcmp(getprogname(), "ping6") == 0) + ipv6 = true; + else + ipv6 = false; #endif ipv4 = false; diff --git a/sbin/ping/ping.8 b/sbin/ping/ping.8 index c76a995b3a5b..dd17725608eb 100644 --- a/sbin/ping/ping.8 +++ b/sbin/ping/ping.8 @@ -28,7 +28,7 @@ .\" @(#)ping.8 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd November 24, 2020 +.Dd November 26, 2020 .Dt PING 8 .Os .Sh NAME @@ -141,6 +141,9 @@ the specific IP version can be requested by or .Fl 6 options, respectively. +For backwards-compatibility, ICMPv6 can also be selected by invoking the binary +as +.Nm ping6 . .Ss Options common to both IPv4 and IPv6 targets .Bl -tag -width indent .It Fl A diff --git a/sbin/ping/tests/ping_test.sh b/sbin/ping/tests/ping_test.sh index 5084b89d5a89..ed95594abbd2 100644 --- a/sbin/ping/tests/ping_test.sh +++ b/sbin/ping/tests/ping_test.sh @@ -53,9 +53,23 @@ ping_6_c1_s8_t1_body() { check_ping_statistics std.out $(atf_get_srcdir)/ping_6_c1_s8_t1.out } +atf_test_case ping6_c1_s8_t1 +ping6_c1_s8_t1_head() { + atf_set "descr" "Use IPv6 when invoked as ping6" +} +ping6_c1_s8_t1_body() { + if ! getaddrinfo -f inet6 localhost 1>/dev/null 2>&1; then + atf_skip "IPv6 is not configured" + fi + atf_check -s exit:0 -o save:std.out -e empty \ + ping6 -c 1 -s 8 -t 1 localhost + check_ping_statistics std.out $(atf_get_srcdir)/ping_6_c1_s8_t1.out +} + atf_init_test_cases() { atf_add_test_case ping_c1_s56_t1 atf_add_test_case ping_6_c1_s8_t1 + atf_add_test_case ping6_c1_s8_t1 } check_ping_statistics() { |