From 93fa94f96fe901ed9f8842bcbfca78a04d77ba34 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Fri, 23 Sep 2016 13:04:33 -0400 Subject: [PATCH] Re-enable support for local addresses. This patch is based on the "RFC: Reenabling the TCP BTL over local interfaces (when specifically requested)". It removes the hardcoded exception for the local devices that has been enforced by the TCP BTL. Instead, we exclude the local interface only via the exclude MCA (both IPv4 and IPv6 local addresses are already in the default if_exclude), which is also the behavior currently described in our README file. --- opal/mca/btl/tcp/btl_tcp_proc.c | 58 ++++++++++----------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/opal/mca/btl/tcp/btl_tcp_proc.c b/opal/mca/btl/tcp/btl_tcp_proc.c index a727a43ff9..f7decc44ff 100644 --- a/opal/mca/btl/tcp/btl_tcp_proc.c +++ b/opal/mca/btl/tcp/btl_tcp_proc.c @@ -541,9 +541,9 @@ int mca_btl_tcp_proc_insert( mca_btl_tcp_proc_t* btl_proc, } - for(i=0; inum_local_interfaces; ++i) { + for( i = 0; i < proc_data->num_local_interfaces; ++i ) { mca_btl_tcp_interface_t* local_interface = proc_data->local_interfaces[i]; - for(j=0; jnum_peer_interfaces; ++j) { + for( j = 0; j < proc_data->num_peer_interfaces; ++j ) { /* initially, assume no connection is possible */ proc_data->weights[i][j] = CQ_NO_CONNECTION; @@ -552,19 +552,8 @@ int mca_btl_tcp_proc_insert( mca_btl_tcp_proc_t* btl_proc, if(NULL != proc_data->local_interfaces[i]->ipv4_address && NULL != peer_interfaces[j]->ipv4_address) { - /* check for loopback */ - if ((opal_net_islocalhost((struct sockaddr *)local_interface->ipv4_address) && - !opal_net_islocalhost((struct sockaddr *)peer_interfaces[j]->ipv4_address)) || - (opal_net_islocalhost((struct sockaddr *)peer_interfaces[j]->ipv4_address) && - !opal_net_islocalhost((struct sockaddr *)local_interface->ipv4_address)) || - (opal_net_islocalhost((struct sockaddr *)local_interface->ipv4_address) && - !opal_ifislocal(proc_hostname))) { - - /* No connection is possible on these interfaces */ - - /* check for RFC1918 */ - } else if(opal_net_addr_isipv4public((struct sockaddr*) local_interface->ipv4_address) && - opal_net_addr_isipv4public((struct sockaddr*) peer_interfaces[j]->ipv4_address)) { + if(opal_net_addr_isipv4public((struct sockaddr*) local_interface->ipv4_address) && + opal_net_addr_isipv4public((struct sockaddr*) peer_interfaces[j]->ipv4_address)) { if(opal_net_samenetwork((struct sockaddr*) local_interface->ipv4_address, (struct sockaddr*) peer_interfaces[j]->ipv4_address, local_interface->ipv4_netmask)) { @@ -574,17 +563,16 @@ int mca_btl_tcp_proc_insert( mca_btl_tcp_proc_t* btl_proc, } proc_data->best_addr[i][j] = peer_interfaces[j]->ipv4_endpoint_addr; continue; - } else { - if(opal_net_samenetwork((struct sockaddr*) local_interface->ipv4_address, - (struct sockaddr*) peer_interfaces[j]->ipv4_address, - local_interface->ipv4_netmask)) { - proc_data->weights[i][j] = CQ_PRIVATE_SAME_NETWORK; - } else { - proc_data->weights[i][j] = CQ_PRIVATE_DIFFERENT_NETWORK; - } - proc_data->best_addr[i][j] = peer_interfaces[j]->ipv4_endpoint_addr; - continue; } + if(opal_net_samenetwork((struct sockaddr*) local_interface->ipv4_address, + (struct sockaddr*) peer_interfaces[j]->ipv4_address, + local_interface->ipv4_netmask)) { + proc_data->weights[i][j] = CQ_PRIVATE_SAME_NETWORK; + } else { + proc_data->weights[i][j] = CQ_PRIVATE_DIFFERENT_NETWORK; + } + proc_data->best_addr[i][j] = peer_interfaces[j]->ipv4_endpoint_addr; + continue; } /* check state of ipv6 address pair - ipv6 is always public, @@ -593,19 +581,9 @@ int mca_btl_tcp_proc_insert( mca_btl_tcp_proc_t* btl_proc, if(NULL != local_interface->ipv6_address && NULL != peer_interfaces[j]->ipv6_address) { - /* check for loopback */ - if ((opal_net_islocalhost((struct sockaddr *)local_interface->ipv6_address) && - !opal_net_islocalhost((struct sockaddr *)peer_interfaces[j]->ipv6_address)) || - (opal_net_islocalhost((struct sockaddr *)peer_interfaces[j]->ipv6_address) && - !opal_net_islocalhost((struct sockaddr *)local_interface->ipv6_address)) || - (opal_net_islocalhost((struct sockaddr *)local_interface->ipv6_address) && - !opal_ifislocal(proc_hostname))) { - - /* No connection is possible on these interfaces */ - - } else if(opal_net_samenetwork((struct sockaddr*) local_interface->ipv6_address, - (struct sockaddr*) peer_interfaces[j]->ipv6_address, - local_interface->ipv6_netmask)) { + if(opal_net_samenetwork((struct sockaddr*) local_interface->ipv6_address, + (struct sockaddr*) peer_interfaces[j]->ipv6_address, + local_interface->ipv6_netmask)) { proc_data->weights[i][j] = CQ_PUBLIC_SAME_NETWORK; } else { proc_data->weights[i][j] = CQ_PUBLIC_DIFFERENT_NETWORK; @@ -758,6 +736,7 @@ int mca_btl_tcp_proc_remove(mca_btl_tcp_proc_t* btl_proc, mca_btl_base_endpoint_ mca_btl_tcp_proc_t* mca_btl_tcp_proc_lookup(const opal_process_name_t *name) { mca_btl_tcp_proc_t* proc = NULL; + OPAL_THREAD_LOCK(&mca_btl_tcp_component.tcp_lock); opal_proc_table_get_value(&mca_btl_tcp_component.tcp_procs, *name, (void**)&proc); @@ -795,9 +774,8 @@ mca_btl_tcp_proc_t* mca_btl_tcp_proc_lookup(const opal_process_name_t *name) */ void mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t* btl_proc, struct sockaddr* addr, int sd) { - size_t i; OPAL_THREAD_LOCK(&btl_proc->proc_lock); - for( i = 0; i < btl_proc->proc_endpoint_count; i++ ) { + for( size_t i = 0; i < btl_proc->proc_endpoint_count; i++ ) { mca_btl_base_endpoint_t* btl_endpoint = btl_proc->proc_endpoints[i]; /* Check all conditions before going to try to accept the connection. */ if( btl_endpoint->endpoint_addr->addr_family != addr->sa_family ) {