| Summary: | Resolver fails to return all addresses of multi-homed hosts in /etc/hosts | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 5 | Reporter: | Alan Matsuoka <alanm> |
| Component: | glibc | Assignee: | Andreas Schwab <schwab> |
| Status: | CLOSED ERRATA | QA Contact: | qe-baseos-tools-bugs |
| Severity: | high | Docs Contact: | |
| Priority: | high | ||
| Version: | 5.5 | CC: | ebachalo, fweimer, mfranc, pmuller, spoyarek |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | glibc-2.5-64 | Doc Type: | Bug Fix |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2011-07-21 08:31:39 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
|
Description
Alan Matsuoka
2011-02-08 17:08:00 UTC
A more accurate reproducer:
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>
void
dump_res (struct addrinfo *p_res)
{
struct addrinfo *iter = p_res;
while (iter != 0)
{
struct sockaddr_in *addr1b;
addr1b = (struct sockaddr_in *) iter->ai_addr;
printf ("getaddrinfo returns: %s %d %d\n", inet_ntoa (addr1b->sin_addr),
iter->ai_family, iter->ai_protocol);
iter = iter->ai_next;
}
}
int
main (int argc, char *argv[])
{
if (argc != 2)
{
printf ("Usage prog hostname\n");
exit (7);
}
struct addrinfo hints, *res;
int error, i;
bzero (&hints, sizeof (hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
for (i = 0; i < 2; i++)
{
printf ("======== ATTEMPT %d ===============\n", i);
if ((error = getaddrinfo (argv[1], NULL, &hints, &res)))
{
perror ("getaddrinfo");
exit (-1);
}
dump_res (res);
freeaddrinfo (res);
}
}
since it does not have anything to do with AF_UNSPEC per say and the earlier reproducer tries to imply otherwise. It's just that the first call does not return all addresses since _res_hconf_init has not been called yet.
// glibc-2.5-57 # getent ahosts multihost multihost 1.1.1.1 STREAM multihost 1.1.1.1 DGRAM 1.1.1.1 RAW 1.1.1.1 STREAM multihost 1.1.1.1 DGRAM 1.1.1.1 RAW 2.2.2.2 STREAM 2.2.2.2 DGRAM 2.2.2.2 RAW 3.3.3.3 STREAM 3.3.3.3 DGRAM 3.3.3.3 RAW // glibc-2.5-57 # ./a.out multihost ======== ATTEMPT 0 =============== getaddrinfo returns: 1.1.1.1 2 6 getaddrinfo returns: 1.1.1.1 2 17 getaddrinfo returns: 1.1.1.1 2 0 ======== ATTEMPT 1 =============== getaddrinfo returns: 1.1.1.1 2 6 getaddrinfo returns: 1.1.1.1 2 17 getaddrinfo returns: 1.1.1.1 2 0 getaddrinfo returns: 2.2.2.2 2 6 getaddrinfo returns: 2.2.2.2 2 17 getaddrinfo returns: 2.2.2.2 2 0 getaddrinfo returns: 3.3.3.3 2 6 getaddrinfo returns: 3.3.3.3 2 17 getaddrinfo returns: 3.3.3.3 2 0 // glibc-2.5-65 # getent ahosts multihost multihost 1.1.1.1 STREAM multihost 1.1.1.1 DGRAM 1.1.1.1 RAW 2.2.2.2 STREAM 2.2.2.2 DGRAM 2.2.2.2 RAW 3.3.3.3 STREAM 3.3.3.3 DGRAM 3.3.3.3 RAW 1.1.1.1 STREAM multihost 1.1.1.1 DGRAM 1.1.1.1 RAW 2.2.2.2 STREAM 2.2.2.2 DGRAM 2.2.2.2 RAW 3.3.3.3 STREAM 3.3.3.3 DGRAM 3.3.3.3 RAW // glibc-2.5-65 ======== ATTEMPT 0 =============== getaddrinfo returns: 1.1.1.1 2 6 getaddrinfo returns: 1.1.1.1 2 17 getaddrinfo returns: 1.1.1.1 2 0 getaddrinfo returns: 2.2.2.2 2 6 getaddrinfo returns: 2.2.2.2 2 17 getaddrinfo returns: 2.2.2.2 2 0 getaddrinfo returns: 3.3.3.3 2 6 getaddrinfo returns: 3.3.3.3 2 17 getaddrinfo returns: 3.3.3.3 2 0 ======== ATTEMPT 1 =============== getaddrinfo returns: 1.1.1.1 2 6 getaddrinfo returns: 1.1.1.1 2 17 getaddrinfo returns: 1.1.1.1 2 0 getaddrinfo returns: 2.2.2.2 2 6 getaddrinfo returns: 2.2.2.2 2 17 getaddrinfo returns: 2.2.2.2 2 0 getaddrinfo returns: 3.3.3.3 2 6 getaddrinfo returns: 3.3.3.3 2 17 getaddrinfo returns: 3.3.3.3 2 0 An advisory 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 therefore 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/RHBA-2011-1034.html |