Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "ping: fix ping6 name resolution for hostnames with link-local…
… addresses" This reverts commit d217170. This removes hints.ai_family = AF_UNSPEC and check for whether the family matches (hopefully the check itself can be removed). Reverting allows pinging IPv4-mapped IPv6 address because getaddrinfo() implementation in glibc supports it already, only AF_UNSPEC enforcement from d217170 disabled effect of -4 [1]: $ ./builddir/ping/ping -4 -c1 ::ffff:127.0.0.1 PING ::ffff:127.0.0.1 (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.061 ms --- ::ffff:127.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.061/0.061/0.061/0.000 ms With this change the behavior matches ping from inetutils [2] and BusyBox. Unfortunately this will not help on musl, which probably does not support IPv4-mapped IPv6 address (although musl wiki does not mention anything about IPv4-mapped IPv6 address support or about any related difference from glibc [3], but libuv issue [4] mentions missing support by default, glibc is mentioned to use ai_flags in AI_ADDRCONFIG | AI_V4MAPPED, but even this does not help). Original effort from issue iputils#252 [5] PR#253 [6] intended to fix pinging IPv6 local scope address without scope ID on raw socket. Fix d217170 enabled it on raw socket, but surprisingly it works even without it: $ ./builddir/ping/ping -v -c1 fe80::fc54:ff:fe29:5693 ./builddir/ping/ping: sock4.fd: 3 (socktype: SOCK_RAW), sock6.fd: 4 (socktype: SOCK_RAW), hints.ai_family: AF_UNSPEC ai->ai_family: AF_INET6, ai->ai_canonname: 'fe80::fc54:ff:fe29:5693' PING fe80::fc54:ff:fe29:5693 (fe80::fc54:ff:fe29:5693) 56 data bytes 64 bytes from fe80::fc54:ff:fe29:5693%vnet0: icmp_seq=1 ident=53558 ttl=64 time=0.066 ms --- fe80::fc54:ff:fe29:5693 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.066/0.066/0.066/0.000 ms This issue was later considered less important (see c4b8b44), because it does not work on ICMP datagram socket anyway. [1] https://lists.busybox.net/pipermail/busybox/2024-October/090985.html [2] https://lists.busybox.net/pipermail/busybox/2024-October/090985.html [3] https://wiki.musl-libc.org/functional-differences-from-glibc.html#Name_Resolver/DNS [4] libuv/libuv#2225 [5] iputils#252 [6] iputils#253 Suggested-by: Vo Ya <[email protected]> Signed-off-by: Petr Vorel <[email protected]>
- Loading branch information