1
1

This patch consists of two parts. Part one is the fixing of a bug in the

determing of the IP subnet.  The netmask was being used improperly when
determining which subnet each connection is on.  Part two is the ability to
include/exclude specific subnets.

This patch fixes ticket #1665

This commit was SVN r20016.
Этот коммит содержится в:
Jon Mason 2008-11-17 20:20:24 +00:00
родитель 5ce4f6fc1d
Коммит 4757970438
3 изменённых файлов: 76 добавлений и 6 удалений

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

@ -211,6 +211,8 @@ struct mca_btl_openib_component_t {
char **if_include_list;
char *if_exclude;
char **if_exclude_list;
char *ipaddr_include;
char *ipaddr_exclude;
/* MCA param btl_openib_receive_queues */
char *receive_queues;

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

@ -155,6 +155,54 @@ static int dev_specified(char *name, int port)
return 0;
}
static int ipaddr_specified(struct sockaddr_in *ipaddr, uint32_t netmask)
{
if (NULL != mca_btl_openib_component.ipaddr_include) {
char **list;
int i;
list = opal_argv_split(mca_btl_openib_component.ipaddr_include, ',');
for (i = 0; NULL != list[i]; i++) {
uint32_t subnet, list_subnet;
struct in_addr ipae;
char **temp = opal_argv_split(list[i], '/');
inet_pton(ipaddr->sin_family, temp[0], &ipae);
list_subnet = ipae.s_addr & ~(~0 << atoi(temp[1]));
subnet = ipaddr->sin_addr.s_addr & ~(~0 << netmask);
if (subnet == list_subnet) {
return 0;
}
}
return 1;
}
if (NULL != mca_btl_openib_component.ipaddr_exclude) {
char **list;
int i;
list = opal_argv_split(mca_btl_openib_component.ipaddr_exclude, ',');
for (i = 0; NULL != list[i]; i++) {
uint32_t subnet, list_subnet;
struct in_addr ipae;
char **temp = opal_argv_split(list[i], '/');
inet_pton(ipaddr->sin_family, temp[0], &ipae);
list_subnet = ipae.s_addr & ~(~0 << atoi(temp[1]));
subnet = ipaddr->sin_addr.s_addr & ~(~0 << netmask);
if (subnet == list_subnet) {
return 1;
}
}
}
return 0;
}
static int add_rdma_addr(struct sockaddr *ipaddr, uint32_t netmask)
{
struct sockaddr_in *sinp;
@ -177,15 +225,25 @@ static int add_rdma_addr(struct sockaddr *ipaddr, uint32_t netmask)
goto out2;
}
/* Bind the newly created cm_id to the IP address. This will, amongst other
things, verify that the device is iWARP capable */
rc = rdma_bind_addr(cm_id, ipaddr);
if (rc || !cm_id->verbs) {
rc = OMPI_SUCCESS;
goto out3;
}
/* Verify that the device has not been excluded */
rc = dev_specified(cm_id->verbs->device->name, cm_id->port_num);
if (rc) {
rc = OMPI_SUCCESS;
goto out3;
}
if (!cm_id->verbs ||
0 == ((struct sockaddr_in *)ipaddr)->sin_addr.s_addr ||
dev_specified(cm_id->verbs->device->name, cm_id->port_num)) {
/* Verify that the device has a valid IP address */
if (0 == ((struct sockaddr_in *)ipaddr)->sin_addr.s_addr ||
ipaddr_specified((struct sockaddr_in *)ipaddr, netmask)) {
rc = OMPI_SUCCESS;
goto out3;
}
@ -198,13 +256,13 @@ static int add_rdma_addr(struct sockaddr *ipaddr, uint32_t netmask)
sinp = (struct sockaddr_in *)ipaddr;
myaddr->addr = sinp->sin_addr.s_addr;
myaddr->subnet = myaddr->addr & netmask;
myaddr->subnet = myaddr->addr & ~(~0 << netmask);
inet_ntop(sinp->sin_family, &sinp->sin_addr,
myaddr->addr_str, sizeof(myaddr->addr_str));
memcpy(myaddr->dev_name, cm_id->verbs->device->name, IBV_SYSFS_NAME_MAX);
myaddr->dev_port = cm_id->port_num;
BTL_VERBOSE(("Adding addr %s (0x%x) as %s:%d",
myaddr->addr_str, myaddr->addr,
BTL_VERBOSE(("Adding addr %s (0x%x) subnet 0x%x as %s:%d",
myaddr->addr_str, myaddr->addr, myaddr->subnet,
myaddr->dev_name, myaddr->dev_port));
opal_list_append(myaddrs, &(myaddr->super));

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

@ -564,6 +564,16 @@ int btl_openib_register_mca_params(void)
NULL, &mca_btl_openib_component.if_exclude,
0));
CHECK(reg_string("ipaddr_include", NULL,
"Comma-delimited list of IP Addresses to be used (e.g. \"192.168.1.0/24\"). Mutually exclusive with btl_openib_ipaddr_exclude.",
NULL, &mca_btl_openib_component.ipaddr_include,
0));
CHECK(reg_string("ipaddr_exclude", NULL,
"Comma-delimited list of IP Addresses to be excluded (e.g. \"192.168.1.0/24\"). Mutually exclusive with btl_openib_ipaddr_include.",
NULL, &mca_btl_openib_component.ipaddr_exclude,
0));
/* Register any MCA params for the connect pseudo-components */
if (OMPI_SUCCESS == ret) {
ret = ompi_btl_openib_connect_base_register();