1
1

If we enable ipv6, we resolve a hosts addresses and check them all against our local interfaces to determine if the given host is us. However, if we don't enable ipv6, we only checked the first address returned. This can cause us to incorrectly identify a hostname as "not us".

Make -disable-ipv6 behave the same as --enable-ipv6 by checking all the returned addresses.

This commit was SVN r28716.
Этот коммит содержится в:
Ralph Castain 2013-07-03 21:41:36 +00:00
родитель d3b49535b5
Коммит bd65937bf3

Просмотреть файл

@ -195,6 +195,7 @@ int opal_ifaddrtoname(const char* if_addr, char* if_name, int length)
int error;
struct addrinfo hints, *res = NULL, *r;
#else
int i;
in_addr_t inaddr;
struct hostent *h;
#endif
@ -253,22 +254,20 @@ int opal_ifaddrtoname(const char* if_addr, char* if_name, int length)
freeaddrinfo (res);
}
#else
inaddr = inet_addr(if_addr);
if (INADDR_NONE == inaddr) {
h = gethostbyname(if_addr);
if (0 == h) {
return OPAL_ERR_NOT_FOUND;
}
memcpy(&inaddr, h->h_addr, sizeof(inaddr));
h = gethostbyname(if_addr);
if (0 == h) {
return OPAL_ERR_NOT_FOUND;
}
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
intf = (opal_if_t*)opal_list_get_next(intf)) {
if (((struct sockaddr_in*) &intf->if_addr)->sin_addr.s_addr == inaddr) {
strncpy(if_name, intf->if_name, length);
return OPAL_SUCCESS;
for (i=0; NULL != h->h_addr_list[i]; i++) {
memcpy(&inaddr, h->h_addr_list[i], sizeof(inaddr));
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
intf = (opal_if_t*)opal_list_get_next(intf)) {
if (((struct sockaddr_in*) &intf->if_addr)->sin_addr.s_addr == inaddr) {
strncpy(if_name, intf->if_name, length);
return OPAL_SUCCESS;
}
}
}
#endif