tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: getaddrinfo(3) on numerical addresses
At Tue, 24 Oct 2017 15:19:29 +0200,
Edgar Fuß <ef%math.uni-bonn.de@localhost> wrote:
> I've noticed[*] that on NetBSD, getaddrinfo(3) does a resolver lookup even
> if presented a numerical address. Is this on purpose? Would it have a
> drawback if it would first try to inet_pton() the address?
> On Linux, it seems to avoid the resolver lookup.
>
> * The problem was net/nagios-plugins' check_ping to stall during a resolver
> malfunction (despite the addresses given numerically). It turned out that
> check_ping, in order to find out whether it needs to call a syntactically
> different ping6 command, checks whether the -H argument is IPv6. It does
> this eventually by calling getaddrinfo() with an AF_INET6 hint, resulting
> in resolver lookups, which failed.
I suspect there's some misunderstanding. To be sure that we talk
about the same thing, please let me ask you to have some experiment:
- compile the pasted code below and name the executable, say, 'gai'
- run the program as follows:
% RES_OPTIONS=debug 2001:db8::1234
- also try this:
% RES_OPTIONS=debug www.netbsd.org
>From the above description, it seems to me that you're saying in both
cases you'll see verbose output. But, from my code inspection, and in
my understanding of it, and with my local experiment with some BSD
variant implementations including a quite old version (6.1) of NetBSD,
the first case should exit very quietly since it doesn't invoke name
resolution using DNS (or for that matter any other name resolution
protocol).
--
JINMEI, Tatuya
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <stdio.h>
int
main(int argc, char **argv) {
struct addrinfo hints, *res;
int error;
if (argc < 2)
return 1;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET6;
if (getaddrinfo(argv[1], NULL, &hints, &res) == 0)
printf("getaddrinfo succeeded\n");
}
Home |
Main Index |
Thread Index |
Old Index