Add ability to specify mcast interfaces by name
This commit was SVN r24691.
Этот коммит содержится в:
родитель
be8a126600
Коммит
c160f5d5a2
@ -19,6 +19,7 @@
|
|||||||
#ifdef HAVE_ARPA_INET_H
|
#ifdef HAVE_ARPA_INET_H
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "opal/mca/mca.h"
|
#include "opal/mca/mca.h"
|
||||||
#include "opal/mca/base/base.h"
|
#include "opal/mca/base/base.h"
|
||||||
@ -97,6 +98,8 @@ int orte_rmcast_base_open(void)
|
|||||||
uint32_t addr, netaddr, netmask;
|
uint32_t addr, netaddr, netmask;
|
||||||
bool assigned;
|
bool assigned;
|
||||||
int rc;
|
int rc;
|
||||||
|
size_t j;
|
||||||
|
bool named_if;
|
||||||
|
|
||||||
if (opened) {
|
if (opened) {
|
||||||
/* ensure we don't go through here twice */
|
/* ensure we don't go through here twice */
|
||||||
@ -183,7 +186,7 @@ int orte_rmcast_base_open(void)
|
|||||||
|
|
||||||
/* multicast interfaces */
|
/* multicast interfaces */
|
||||||
mca_base_param_reg_string_name("rmcast", "base_if_include",
|
mca_base_param_reg_string_name("rmcast", "base_if_include",
|
||||||
"Comma-separated list of interfaces (given in IP form) to use for multicast messages",
|
"Comma-separated list of interfaces to use for multicast messages",
|
||||||
false, false, NULL, &tmp);
|
false, false, NULL, &tmp);
|
||||||
/* if nothing was provided, default to first non-loopback interface */
|
/* if nothing was provided, default to first non-loopback interface */
|
||||||
lb = -1;
|
lb = -1;
|
||||||
@ -225,6 +228,34 @@ int orte_rmcast_base_open(void)
|
|||||||
idx = -1;
|
idx = -1;
|
||||||
assigned = false;
|
assigned = false;
|
||||||
for (i=0; NULL != nets[i] && !assigned; i++) {
|
for (i=0; NULL != nets[i] && !assigned; i++) {
|
||||||
|
OPAL_OUTPUT_VERBOSE((5, orte_rmcast_base.rmcast_output,
|
||||||
|
"%s rmcast:base checking interface %s",
|
||||||
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), nets[i]));
|
||||||
|
/* if the specified interface contains letters in it, then it
|
||||||
|
* was given as an interface name and not an IP tuple
|
||||||
|
*/
|
||||||
|
named_if = false;
|
||||||
|
for (j=0; j < strlen(nets[i]); j++) {
|
||||||
|
if (isalpha(nets[i][j]) && '.' != nets[i][j]) {
|
||||||
|
named_if = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (named_if) {
|
||||||
|
if (0 > (idx = opal_ifnametoindex(nets[i]))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (ORTE_SUCCESS != (rc = opal_ifindextoaddr(idx, (struct sockaddr*)&inaddr, sizeof(inaddr)))) {
|
||||||
|
ORTE_ERROR_LOG(rc);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
OPAL_OUTPUT_VERBOSE((5, orte_rmcast_base.rmcast_output,
|
||||||
|
"%s rmcast:base using named interface %s",
|
||||||
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), nets[i]));
|
||||||
|
orte_rmcast_base.interface = ntohl(inaddr.sin_addr.s_addr);
|
||||||
|
assigned = true;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
if (ORTE_SUCCESS != (rc = opal_iftupletoaddr(nets[i], &netaddr, &netmask))) {
|
if (ORTE_SUCCESS != (rc = opal_iftupletoaddr(nets[i], &netaddr, &netmask))) {
|
||||||
orte_show_help("help-rmcast-base.txt", "invalid-net-mask", true, nets[i], ORTE_ERROR_NAME(rc));
|
orte_show_help("help-rmcast-base.txt", "invalid-net-mask", true, nets[i], ORTE_ERROR_NAME(rc));
|
||||||
return ORTE_ERR_SILENT;
|
return ORTE_ERR_SILENT;
|
||||||
@ -243,6 +274,9 @@ int orte_rmcast_base_open(void)
|
|||||||
}
|
}
|
||||||
addr = ntohl(inaddr.sin_addr.s_addr);
|
addr = ntohl(inaddr.sin_addr.s_addr);
|
||||||
if (netaddr == (addr & netmask)) {
|
if (netaddr == (addr & netmask)) {
|
||||||
|
OPAL_OUTPUT_VERBOSE((5, orte_rmcast_base.rmcast_output,
|
||||||
|
"%s rmcast:base using IP interface %03d.%03d.%03d.%03d",
|
||||||
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), OPAL_IF_FORMAT_ADDR(addr)));
|
||||||
orte_rmcast_base.interface = ntohl(inaddr.sin_addr.s_addr);
|
orte_rmcast_base.interface = ntohl(inaddr.sin_addr.s_addr);
|
||||||
assigned = true;
|
assigned = true;
|
||||||
break;
|
break;
|
||||||
@ -250,8 +284,9 @@ int orte_rmcast_base_open(void)
|
|||||||
idx = opal_ifnext(idx);
|
idx = opal_ifnext(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
opal_argv_free(nets);
|
opal_argv_free(nets);
|
||||||
if (idx < 0) {
|
if (!assigned) {
|
||||||
orte_show_help("help-rmcast-base.txt", "no-avail-interfaces", true);
|
orte_show_help("help-rmcast-base.txt", "no-avail-interfaces", true);
|
||||||
return ORTE_ERR_SILENT;
|
return ORTE_ERR_SILENT;
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user