Red Hat Bugzilla – Full Text Bug Listing
|Summary:||getnameinfo does not use /etc/hosts for lookup of V4MAPPED addresses|
|Product:||Red Hat Enterprise Linux 3||Reporter:||Joe Orton <jorton>|
|Component:||glibc||Assignee:||Jakub Jelinek <jakub>|
|Status:||CLOSED ERRATA||QA Contact:||Brian Brock <bbrock>|
|Fixed In Version:||Doc Type:||Bug Fix|
|Doc Text:||Story Points:||---|
|Last Closed:||2004-12-20 13:14:11 EST||Type:||---|
|oVirt Team:||---||RHEL 7.3 requirements from Atomic Host:|
Description Joe Orton 2004-05-19 10:25:38 EDT
Reported by Jeff Trawick. I'll attach a modified version of Jeff's gni_mapped.c test program which does a getnameinfo lookup of 10.20.30.40, first using a sockaddr_in, then using the same address as a v4-mapped IPv6 address in a sockaddr_in6. For the first case, getnameinfo does use /etc/hosts; for the second, it does not. $ make gni_mapped $ grep 10.20.30.40 /etc/hosts 10.20.30.40 www.example.com $ ./gni_mapped look up via IPv4: 0/www.example.com look up via IPv6: -2/not found
Comment 1 Joe Orton 2004-05-19 10:26:39 EDT
Created attachment 100333 [details] repro case for getnameinfo bug
Comment 2 Ulrich Drepper 2004-05-25 20:55:35 EDT
This behavior is by design. getnameinfo will return the IPv6 address if /etc/resolv.conf has an "options" line containing "inet6". I.e., add options inet6 to that file and try again. What we probably should do is to add this option to resolv.conf whenever /etc/sysconfig/network contains NETWORKING_IPV6=yes So this bug should probably be handled as a system-config-network bug. I'll reassign.
Comment 3 Joe Orton 2004-05-26 03:21:49 EDT
Well, that might work if every gethostbyname user would cope with 16-byte IPv4-mapped IPv6 addresses in the hostent, but they don't, they expect 4-byte IPv4 addresses. So the gethostbyname world breaks. Why can't getnameinfo() just DTRT here? On FC2: $ grep options /etc/resolv.conf options inet6 $ ping www.redhat.com PING www.redhat.com (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=0 ttl=64 time=0.038 ms64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.073 ms --- www.redhat.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 0.038/0.055/0.073/0.019 ms, pipe 2 $ grep options /etc/resolv.conf $ ping www.redhat.com PING www.redhat.com (188.8.131.52) 56(84) bytes of data. --- www.redhat.com ping statistics --- 2 packets transmitted, 0 received, 100% packet loss, time 999ms
Comment 4 Ulrich Drepper 2004-05-26 03:42:39 EDT
> Well, that might work if every gethostbyname user would cope with > 16-byte IPv4-mapped IPv6 addresses in the hostent, but they don't, > they expect 4-byte IPv4 addresses. So the gethostbyname world breaks. No, why should it? gethostbyname never returns IPv6 addresses. gethostbyname2 does it only if af == AF_INET6. Likewise for gethostbyaddr. No program gets addresses in an unexpected format. > Why can't getnameinfo() just DTRT here? This is the intended behavior.
Comment 5 Joe Orton 2004-05-26 04:05:28 EDT
Empirically, that's exactly what it does, have you tried it? Also matches what resolv.conf(5) says: inet6 sets RES_USE_INET6 in _res.options. This has the effect of trying a AAAA query before an A query inside the gethostbyname function, and of mapping IPv4 responses in IPv6 ââtunnelled formââ if no AAAA records are found but an A record set exists. > > Why can't getnameinfo() just DTRT here? > This is the intended behavior. Why, what's the rationale for specifically ignoring /etc/hosts in this case?
Comment 7 Joe Orton 2004-05-26 04:10:58 EDT
(in case it wasn't clear; getnameinfo does work correctly for IPv4-mapped IPv6 addresses when it really uses DNS; this bug is just that it fails to use /etc/hosts)
Comment 8 Ulrich Drepper 2004-05-26 12:16:43 EDT
I have checked in a change which will, for this case, indeed cause the correct result to be returned. Still, adding the inet6 option is still a good idea. > and what about bug #124376 in this context? Doesn't have much to do with it. If the getaddrinfo() function is used correctly, it will look up IPv6 addresses only if any interface has an IPv6 address configured. Since loading the ipv6 kernel modules automatically assigns link-local addresses to all interface this means IPv6 lookup happens every time when the ipv6 module is loaded. To prevent it the module must be stopped from being loaded.
Comment 11 Jakub Jelinek 2004-10-06 14:27:44 EDT
The patch is in glibc-2.3.2-95.28 which ought to appear in U4 beta.
Comment 12 John Flanagan 2004-12-20 13:14:11 EST
An errata has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHSA-2004-586.html