* Per ticket #112, localhost checks should check against 127.0.0.1/8, rather
than just 127.0.0.1. This commit was SVN r10750.
Этот коммит содержится в:
родитель
682a6a123e
Коммит
4b70bb92db
2
NEWS
2
NEWS
@ -25,6 +25,8 @@ version 1.0.
|
||||
1.2
|
||||
---
|
||||
|
||||
- Properly check for local host only addresses properly, looking
|
||||
for 127.0.0.0/8, rather than just 127.0.0.1.
|
||||
- Addition of OpenIB-based unreliable datagram BTL ("ud").
|
||||
- Addition of UDAPL BTL ("udapl").
|
||||
|
||||
|
@ -633,6 +633,31 @@ int opal_ifindextoname(int if_index, char* if_name, int length)
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
opal_ifislocalhost(struct sockaddr *addr)
|
||||
{
|
||||
switch (addr->sa_family) {
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in *inaddr = (struct sockaddr_in*) addr;
|
||||
/* if it's in the 127. domain, it shouldn't be routed */
|
||||
if (0x74000000 & htonl(inaddr->sin_addr.s_addr)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
opal_output(0, "unhandled sa_family %d passed to opal_ifislocalhost",
|
||||
addr->sa_family);
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define ADDRLEN 100
|
||||
bool
|
||||
opal_ifislocal(char *hostname)
|
||||
@ -721,6 +746,12 @@ opal_ifislocal(char *hostname)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
opal_ifislocalhost(struct sockaddr *addr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
opal_iffinalize(void)
|
||||
{
|
||||
|
@ -113,6 +113,19 @@ OMPI_DECLSPEC int opal_ifindextomask(int if_index, struct sockaddr*, int);
|
||||
*/
|
||||
OMPI_DECLSPEC bool opal_ifislocal(char *hostname);
|
||||
|
||||
/**
|
||||
* Determine if given IP address is in the localhost range
|
||||
*
|
||||
* Determine if the given IP address is in the localhost range
|
||||
* (127.0.0.0/8), meaning that it can't be used to connect to machines
|
||||
* outside the current host.
|
||||
*
|
||||
* @param addr struct sockaddr_in of IP address
|
||||
* @return true if \c addr is a localhost address,
|
||||
* false otherwise.
|
||||
*/
|
||||
OMPI_DECLSPEC bool opal_ifislocalhost(struct sockaddr *addr);
|
||||
|
||||
/**
|
||||
* Finalize the functions to release malloc'd data
|
||||
*
|
||||
|
@ -1001,7 +1001,8 @@ char* mca_oob_tcp_get_addr(void)
|
||||
strstr(mca_oob_tcp_component.tcp_exclude,name) != NULL)
|
||||
continue;
|
||||
opal_ifindextoaddr(i, (struct sockaddr*)&addr, sizeof(addr));
|
||||
if(opal_ifcount() > 1 && addr.sin_addr.s_addr == inet_addr("127.0.0.1"))
|
||||
if(opal_ifcount() > 1 &&
|
||||
opal_ifislocalhost((struct sockaddr*) &addr))
|
||||
continue;
|
||||
if(ptr != contact_info) {
|
||||
ptr += sprintf(ptr, ";");
|
||||
|
@ -72,7 +72,8 @@ int mca_oob_tcp_addr_pack(orte_buffer_t* buffer)
|
||||
for(i=opal_ifbegin(); i>0; i=opal_ifnext(i)) {
|
||||
struct sockaddr_in inaddr;
|
||||
opal_ifindextoaddr(i, (struct sockaddr*)&inaddr, sizeof(inaddr));
|
||||
if(opal_ifcount() > 1 && inaddr.sin_addr.s_addr == inet_addr("127.0.0.1"))
|
||||
if(opal_ifcount() > 1 &&
|
||||
opal_ifislocalhost((struct sockaddr*) &inaddr))
|
||||
continue;
|
||||
count++;
|
||||
}
|
||||
@ -83,7 +84,8 @@ int mca_oob_tcp_addr_pack(orte_buffer_t* buffer)
|
||||
for(i=opal_ifbegin(); i>0; i=opal_ifnext(i)) {
|
||||
struct sockaddr_in inaddr;
|
||||
opal_ifindextoaddr(i, (struct sockaddr*)&inaddr, sizeof(inaddr));
|
||||
if(opal_ifcount() > 1 && inaddr.sin_addr.s_addr == inet_addr("127.0.0.1"))
|
||||
if(opal_ifcount() > 1 &&
|
||||
opal_ifislocalhost((struct sockaddr*) &inaddr))
|
||||
continue;
|
||||
inaddr.sin_port = mca_oob_tcp_component.tcp_listen_port;
|
||||
orte_dss.pack(buffer,&inaddr,sizeof(inaddr),ORTE_BYTE);
|
||||
@ -155,7 +157,8 @@ int mca_oob_tcp_addr_get_next(mca_oob_tcp_addr_t* addr, struct sockaddr_in* retv
|
||||
strstr(mca_oob_tcp_component.tcp_exclude,name) != NULL)
|
||||
continue;
|
||||
opal_ifindextoaddr(ifindex, (struct sockaddr*)&inaddr, sizeof(inaddr));
|
||||
if(opal_ifcount() > 1 && inaddr.sin_addr.s_addr == inet_addr("127.0.0.1"))
|
||||
if(opal_ifcount() > 1 &&
|
||||
opal_ifislocalhost((struct sockaddr*) &inaddr))
|
||||
continue;
|
||||
opal_ifindextomask(ifindex, (struct sockaddr*)&inmask, sizeof(inmask));
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user