1
1

Update the TCP BTL in order to bring back some of the functionalities lost

during the IPv6 patch. The most important is the multi BTL support. There
was a quite interesting bug. Instead of setting up the multiple connections
over different physical devices, based on the time when these connections
were created most of the time they were all using the same physical network.
Which, of course, was not the intended goal, as we top at the maximum
bandwidth available over one device instead of gathering all available
bandwidth from all devices.

Second, the IPv6 RFC suggest to use sockaddr_storage as a holder for the
IP information, but use a sockaddr* when we pass it to functions. This is
only partially corrected by this patch.

Some other minor cleanups.

This commit was SVN r14544.
Этот коммит содержится в:
George Bosilca 2007-04-28 19:13:47 +00:00
родитель 4c453caab6
Коммит 46265db0a9
7 изменённых файлов: 121 добавлений и 201 удалений

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

@ -2,7 +2,7 @@
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University * Copyright (c) 2004-2007 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -70,12 +70,11 @@ mca_btl_tcp_module_t mca_btl_tcp_module = {
* *
*/ */
int mca_btl_tcp_add_procs( int mca_btl_tcp_add_procs( struct mca_btl_base_module_t* btl,
struct mca_btl_base_module_t* btl,
size_t nprocs, size_t nprocs,
struct ompi_proc_t **ompi_procs, struct ompi_proc_t **ompi_procs,
struct mca_btl_base_endpoint_t** peers, struct mca_btl_base_endpoint_t** peers,
ompi_bitmap_t* reachable) ompi_bitmap_t* reachable )
{ {
mca_btl_tcp_module_t* tcp_btl = (mca_btl_tcp_module_t*)btl; mca_btl_tcp_module_t* tcp_btl = (mca_btl_tcp_module_t*)btl;
ompi_proc_t* my_proc; /* pointer to caller's proc structure */ ompi_proc_t* my_proc; /* pointer to caller's proc structure */
@ -86,7 +85,6 @@ int mca_btl_tcp_add_procs(
if( NULL == my_proc ) { if( NULL == my_proc ) {
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
for(i = 0; i < (int) nprocs; i++) { for(i = 0; i < (int) nprocs; i++) {
struct ompi_proc_t* ompi_proc = ompi_procs[i]; struct ompi_proc_t* ompi_proc = ompi_procs[i];

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

@ -2,7 +2,7 @@
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University * Copyright (c) 2004-2007 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -53,9 +53,6 @@ struct mca_btl_tcp_addr_t {
uint32_t _pad[3]; uint32_t _pad[3];
} _addr__inet; } _addr__inet;
} _union_inet; } _union_inet;
#if 0
# define s_addr _union_inet._addr__inet._addr_inet.s_addr
#endif
} addr_inet; } addr_inet;
#endif #endif
in_port_t addr_port; /**< listen port */ in_port_t addr_port; /**< listen port */

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

@ -2,7 +2,7 @@
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University * Copyright (c) 2004-2007 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -15,10 +15,6 @@
* *
* $HEADER$ * $HEADER$
* *
* In windows, many of the socket functions return an EWOULDBLOCK
* instead of \ things like EAGAIN, EINPROGRESS, etc. It has been
* verified that this will \ not conflict with other error codes that
* are returned by these functions \ under UNIX/Linux environments
*/ */
#include "ompi_config.h" #include "ompi_config.h"
@ -161,8 +157,8 @@ OBJ_CLASS_INSTANCE(
/* /*
* functions for receiving event callbacks * functions for receiving event callbacks
*/ */
static void mca_btl_tcp_component_recv_handler(int, short, void*); static void mca_btl_tcp_component_recv_handler(int, short, void*);
static void mca_btl_tcp_component_accept_handler(int, short, void*);
/* /*
@ -597,31 +593,28 @@ static int mca_btl_tcp_component_create_listen(uint16_t af_family)
/* register listen port */ /* register listen port */
#if OPAL_WANT_IPV6 #if OPAL_WANT_IPV6
if (AF_INET == af_family) { if (AF_INET == af_family) {
opal_event_set( opal_event_set( &mca_btl_tcp_component.tcp_recv_event,
&mca_btl_tcp_component.tcp_recv_event,
sd, sd,
OPAL_EV_READ|OPAL_EV_PERSIST, OPAL_EV_READ|OPAL_EV_PERSIST,
mca_btl_tcp_component_recv_handler, mca_btl_tcp_component_accept_handler,
0); 0 );
opal_event_add(&mca_btl_tcp_component.tcp_recv_event, 0); opal_event_add(&mca_btl_tcp_component.tcp_recv_event, 0);
} }
if (AF_INET6 == af_family) { if (AF_INET6 == af_family) {
opal_event_set( opal_event_set( &mca_btl_tcp_component.tcp6_recv_event,
&mca_btl_tcp_component.tcp6_recv_event,
sd, sd,
OPAL_EV_READ|OPAL_EV_PERSIST, OPAL_EV_READ|OPAL_EV_PERSIST,
mca_btl_tcp_component_recv_handler, mca_btl_tcp_component_accept_handler,
0); 0 );
opal_event_add(&mca_btl_tcp_component.tcp6_recv_event, 0); opal_event_add(&mca_btl_tcp_component.tcp6_recv_event, 0);
} }
#else #else
opal_event_set( opal_event_set( &mca_btl_tcp_component.tcp_recv_event,
&mca_btl_tcp_component.tcp_recv_event,
mca_btl_tcp_component.tcp_listen_sd, mca_btl_tcp_component.tcp_listen_sd,
OPAL_EV_READ|OPAL_EV_PERSIST, OPAL_EV_READ|OPAL_EV_PERSIST,
mca_btl_tcp_component_recv_handler, mca_btl_tcp_component_accept_handler,
0); 0 );
opal_event_add(&mca_btl_tcp_component.tcp_recv_event,0); opal_event_add(&mca_btl_tcp_component.tcp_recv_event,0);
#endif #endif
return OMPI_SUCCESS; return OMPI_SUCCESS;
@ -634,12 +627,10 @@ static int mca_btl_tcp_component_create_listen(uint16_t af_family)
static int mca_btl_tcp_component_exchange(void) static int mca_btl_tcp_component_exchange(void)
{ {
int rc=0; int rc = 0, index;
size_t i=0; size_t i = 0;
int index;
size_t size = mca_btl_tcp_component.tcp_addr_count * size_t size = mca_btl_tcp_component.tcp_addr_count *
mca_btl_tcp_component.tcp_num_links * mca_btl_tcp_component.tcp_num_links * sizeof(mca_btl_tcp_addr_t);
sizeof(mca_btl_tcp_addr_t);
/* adi@2007-04-12: /* adi@2007-04-12:
* *
* We'll need to explain things a bit here: * We'll need to explain things a bit here:
@ -652,10 +643,10 @@ static int mca_btl_tcp_component_exchange(void)
if(mca_btl_tcp_component.tcp_num_btls != 0) { if(mca_btl_tcp_component.tcp_num_btls != 0) {
mca_btl_tcp_addr_t *addrs = (mca_btl_tcp_addr_t *)malloc(size); mca_btl_tcp_addr_t *addrs = (mca_btl_tcp_addr_t *)malloc(size);
memset (addrs, 0, size); memset(addrs, 0, size);
/* here we start populating our addresses */ /* here we start populating our addresses */
for (i=0; i < mca_btl_tcp_component.tcp_num_btls; i++) { for( i = 0; i < mca_btl_tcp_component.tcp_num_btls; i++ ) {
for (index = opal_ifbegin(); index >= 0; for (index = opal_ifbegin(); index >= 0;
index = opal_ifnext(index)) { index = opal_ifnext(index)) {
struct sockaddr_storage my_ss; struct sockaddr_storage my_ss;
@ -798,14 +789,14 @@ int mca_btl_tcp_component_control(int param, void* value, size_t size)
} }
/* /**
* Called by mca_btl_tcp_component_recv() when the TCP listen * Called by the event engine when the listening socket has
* socket has pending connection requests. Accept incoming * a connection event. Accept the incoming connection request
* requests and queue for completion of the connection handshake. * and queue them for completion of the connection handshake.
*/ */
static void mca_btl_tcp_component_accept_handler( int incoming_sd,
short ignored,
static void mca_btl_tcp_component_accept(int incoming_sd) void* unused )
{ {
while(true) { while(true) {
#if OPAL_WANT_IPV6 #if OPAL_WANT_IPV6
@ -836,34 +827,21 @@ static void mca_btl_tcp_component_accept(int incoming_sd)
} }
/* /**
* Event callback when there is data available on the registered * Event callback when there is data available on the registered
* socket to recv. * socket to recv. This callback is triggered only once per lifetime
* for any socket, in the beginning when we setup the handshake
* protocol.
*/ */
static void mca_btl_tcp_component_recv_handler(int sd, short flags, void* user) static void mca_btl_tcp_component_recv_handler(int sd, short flags, void* user)
{ {
orte_process_name_t guid; orte_process_name_t guid;
/* Bug, FIXME: use sockaddr_storage instead? */ struct sockaddr_storage addr;
#if OPAL_WANT_IPV6
struct sockaddr_in6 addr;
#else
struct sockaddr_in addr;
#endif
int retval; int retval;
mca_btl_tcp_proc_t* btl_proc; mca_btl_tcp_proc_t* btl_proc;
opal_socklen_t addr_len = sizeof(addr); opal_socklen_t addr_len = sizeof(addr);
mca_btl_tcp_event_t *event = (mca_btl_tcp_event_t *)user; mca_btl_tcp_event_t *event = (mca_btl_tcp_event_t *)user;
/* accept new connections on the listen socket */
#if OPAL_WANT_IPV6
if((mca_btl_tcp_component.tcp_listen_sd == sd) ||
(mca_btl_tcp_component.tcp6_listen_sd == sd)) {
#else
if(mca_btl_tcp_component.tcp_listen_sd == sd) {
#endif
mca_btl_tcp_component_accept(sd);
return;
}
OBJ_RELEASE(event); OBJ_RELEASE(event);
/* recv the process identifier */ /* recv the process identifier */
@ -902,7 +880,7 @@ static void mca_btl_tcp_component_recv_handler(int sd, short flags, void* user)
} }
/* are there any existing peer instances will to accept this connection */ /* are there any existing peer instances will to accept this connection */
if(mca_btl_tcp_proc_accept(btl_proc, (struct sockaddr_storage*)&addr, sd) == false) { if(mca_btl_tcp_proc_accept(btl_proc, (struct sockaddr*)&addr, sd) == false) {
CLOSE_THE_SOCKET(sd); CLOSE_THE_SOCKET(sd);
return; return;
} }

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

@ -2,7 +2,7 @@
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University * Copyright (c) 2004-2007 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -15,10 +15,6 @@
* *
* $HEADER$ * $HEADER$
* *
* In windows, many of the socket functions return an EWOULDBLOCK
* instead of \ things like EAGAIN, EINPROGRESS, etc. It has been
* verified that this will \ not conflict with other error codes that
* are returned by these functions \ under UNIX/Linux environments
*/ */
#include "ompi_config.h" #include "ompi_config.h"
@ -65,7 +61,6 @@
* Initialize state of the endpoint instance. * Initialize state of the endpoint instance.
* *
*/ */
static void mca_btl_tcp_endpoint_construct(mca_btl_tcp_endpoint_t* endpoint) static void mca_btl_tcp_endpoint_construct(mca_btl_tcp_endpoint_t* endpoint)
{ {
endpoint->endpoint_btl = NULL; endpoint->endpoint_btl = NULL;
@ -93,8 +88,6 @@ static void mca_btl_tcp_endpoint_construct(mca_btl_tcp_endpoint_t* endpoint)
* Destroy a endpoint * Destroy a endpoint
* *
*/ */
static void mca_btl_tcp_endpoint_destruct(mca_btl_tcp_endpoint_t* endpoint) static void mca_btl_tcp_endpoint_destruct(mca_btl_tcp_endpoint_t* endpoint)
{ {
mca_btl_tcp_proc_remove(endpoint->endpoint_proc, endpoint); mca_btl_tcp_proc_remove(endpoint->endpoint_proc, endpoint);
@ -236,6 +229,7 @@ static inline void mca_btl_tcp_endpoint_event_init(mca_btl_base_endpoint_t* btl_
int mca_btl_tcp_endpoint_send(mca_btl_base_endpoint_t* btl_endpoint, mca_btl_tcp_frag_t* frag) int mca_btl_tcp_endpoint_send(mca_btl_base_endpoint_t* btl_endpoint, mca_btl_tcp_frag_t* frag)
{ {
int rc = OMPI_SUCCESS; int rc = OMPI_SUCCESS;
OPAL_THREAD_LOCK(&btl_endpoint->endpoint_send_lock); OPAL_THREAD_LOCK(&btl_endpoint->endpoint_send_lock);
switch(btl_endpoint->endpoint_state) { switch(btl_endpoint->endpoint_state) {
case MCA_BTL_TCP_CONNECTING: case MCA_BTL_TCP_CONNECTING:
@ -326,13 +320,12 @@ static int mca_btl_tcp_endpoint_send_connect_ack(mca_btl_base_endpoint_t* btl_en
*/ */
bool mca_btl_tcp_endpoint_accept(mca_btl_base_endpoint_t* btl_endpoint, bool mca_btl_tcp_endpoint_accept(mca_btl_base_endpoint_t* btl_endpoint,
struct sockaddr_storage* addr, int sd) struct sockaddr* addr, int sd)
{ {
mca_btl_tcp_addr_t* btl_addr; mca_btl_tcp_addr_t* btl_addr;
mca_btl_tcp_proc_t* this_proc = mca_btl_tcp_proc_local(); mca_btl_tcp_proc_t* this_proc = mca_btl_tcp_proc_local();
orte_ns_cmp_bitmask_t mask = ORTE_NS_CMP_ALL; mca_btl_tcp_proc_t *endpoint_proc = btl_endpoint->endpoint_proc;
int cmpval; int cmpval;
bool addrs_match = false;
OPAL_THREAD_LOCK(&btl_endpoint->endpoint_recv_lock); OPAL_THREAD_LOCK(&btl_endpoint->endpoint_recv_lock);
OPAL_THREAD_LOCK(&btl_endpoint->endpoint_send_lock); OPAL_THREAD_LOCK(&btl_endpoint->endpoint_send_lock);
@ -343,38 +336,7 @@ bool mca_btl_tcp_endpoint_accept(mca_btl_base_endpoint_t* btl_endpoint,
return false; return false;
} }
#if 0 cmpval = orte_ns.compare_fields(ORTE_NS_CMP_ALL,
if (btl_addr->addr_family != addr->ss_family) {
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock);
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock);
return false;
}
switch (addr->ss_family) {
case AF_INET:
if (((__const uint32_t *)&btl_addr->addr_inet)[0] ==
((struct sockaddr_in*)addr)->sin_addr.s_addr) {
addrs_match = true;
}
break;
#if OPAL_WANT_IPV6
case AF_INET6:
if (IN6_ARE_ADDR_EQUAL (&btl_addr->addr_inet,
&((struct sockaddr_in6*)addr)->sin6_addr)) {
addrs_match = true;
}
break;
#endif
default:
opal_output(0, "mca_btl_tcp_endpoint_accept: unknown af_family: %i\n",
addr->ss_family);
}
#else
addrs_match = true;
#endif
if (true == addrs_match) {
mca_btl_tcp_proc_t *endpoint_proc = btl_endpoint->endpoint_proc;
cmpval = orte_ns.compare_fields(mask,
&endpoint_proc->proc_ompi->proc_name, &endpoint_proc->proc_ompi->proc_name,
&this_proc->proc_ompi->proc_name); &this_proc->proc_ompi->proc_name);
if((btl_endpoint->endpoint_sd < 0) || if((btl_endpoint->endpoint_sd < 0) ||
@ -398,7 +360,6 @@ bool mca_btl_tcp_endpoint_accept(mca_btl_base_endpoint_t* btl_endpoint,
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock); OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock);
return true; return true;
} }
}
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock); OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock);
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock); OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock);
return false; return false;
@ -410,7 +371,6 @@ bool mca_btl_tcp_endpoint_accept(mca_btl_base_endpoint_t* btl_endpoint,
* and update the endpoint state to reflect the connection has * and update the endpoint state to reflect the connection has
* been closed. * been closed.
*/ */
void mca_btl_tcp_endpoint_close(mca_btl_base_endpoint_t* btl_endpoint) void mca_btl_tcp_endpoint_close(mca_btl_base_endpoint_t* btl_endpoint)
{ {
if(btl_endpoint->endpoint_sd >= 0) { if(btl_endpoint->endpoint_sd >= 0) {
@ -492,13 +452,11 @@ static int mca_btl_tcp_endpoint_recv_blocking(mca_btl_base_endpoint_t* btl_endpo
} }
/* /*
* Receive the endpoints globally unique process identification from a newly * Receive the endpoints globally unique process identification from a newly
* connected socket and verify the expected response. If so, move the * connected socket and verify the expected response. If so, move the
* socket to a connected state. * socket to a connected state.
*/ */
static int mca_btl_tcp_endpoint_recv_connect_ack(mca_btl_base_endpoint_t* btl_endpoint) static int mca_btl_tcp_endpoint_recv_connect_ack(mca_btl_base_endpoint_t* btl_endpoint)
{ {
orte_process_name_t guid; orte_process_name_t guid;
@ -508,7 +466,6 @@ static int mca_btl_tcp_endpoint_recv_connect_ack(mca_btl_base_endpoint_t* btl_en
return OMPI_ERR_UNREACH; return OMPI_ERR_UNREACH;
} }
ORTE_PROCESS_NAME_NTOH(guid); ORTE_PROCESS_NAME_NTOH(guid);
/* compare this to the expected values */ /* compare this to the expected values */
if(memcmp(&btl_proc->proc_name, &guid, sizeof(orte_process_name_t)) != 0) { if(memcmp(&btl_proc->proc_name, &guid, sizeof(orte_process_name_t)) != 0) {
BTL_ERROR(("received unexpected process identifier [%lu,%lu,%lu]", BTL_ERROR(("received unexpected process identifier [%lu,%lu,%lu]",
@ -561,18 +518,14 @@ void mca_btl_tcp_set_socket_options(int sd)
* our globally unique process identifier to the endpoint and wait for * our globally unique process identifier to the endpoint and wait for
* the endpoints response. * the endpoints response.
*/ */
static int mca_btl_tcp_endpoint_start_connect(mca_btl_base_endpoint_t* btl_endpoint) static int mca_btl_tcp_endpoint_start_connect(mca_btl_base_endpoint_t* btl_endpoint)
{ {
int rc,flags; int rc,flags;
struct sockaddr_storage endpoint_addr; struct sockaddr_storage endpoint_addr;
uint16_t af_family; /* By default consider a IPv4 connection */
opal_socklen_t addrlen; uint16_t af_family = AF_INET;
opal_socklen_t addrlen = sizeof(struct sockaddr_in);
if (AF_INET == btl_endpoint->endpoint_addr->addr_family) {
af_family = AF_INET;
addrlen = sizeof (struct sockaddr_in);
}
#if OPAL_WANT_IPV6 #if OPAL_WANT_IPV6
if (AF_INET6 == btl_endpoint->endpoint_addr->addr_family) { if (AF_INET6 == btl_endpoint->endpoint_addr->addr_family) {
af_family = AF_INET6; af_family = AF_INET6;
@ -641,7 +594,6 @@ static int mca_btl_tcp_endpoint_start_connect(mca_btl_base_endpoint_t* btl_endpo
* later. Otherwise, send this processes identifier to the endpoint on the * later. Otherwise, send this processes identifier to the endpoint on the
* newly connected socket. * newly connected socket.
*/ */
static void mca_btl_tcp_endpoint_complete_connect(mca_btl_base_endpoint_t* btl_endpoint) static void mca_btl_tcp_endpoint_complete_connect(mca_btl_base_endpoint_t* btl_endpoint)
{ {
int so_error = 0; int so_error = 0;
@ -768,7 +720,6 @@ static void mca_btl_tcp_endpoint_send_handler(int sd, short flags, void* user)
mca_btl_tcp_endpoint_complete_connect(btl_endpoint); mca_btl_tcp_endpoint_complete_connect(btl_endpoint);
break; break;
case MCA_BTL_TCP_CONNECTED: case MCA_BTL_TCP_CONNECTED:
{
/* complete the current send */ /* complete the current send */
do { do {
mca_btl_tcp_frag_t* frag = btl_endpoint->endpoint_send_frag; mca_btl_tcp_frag_t* frag = btl_endpoint->endpoint_send_frag;
@ -791,7 +742,6 @@ static void mca_btl_tcp_endpoint_send_handler(int sd, short flags, void* user)
opal_event_del(&btl_endpoint->endpoint_send_event); opal_event_del(&btl_endpoint->endpoint_send_event);
} }
break; break;
}
default: default:
BTL_ERROR(("invalid connection state (%d)", btl_endpoint->endpoint_state)); BTL_ERROR(("invalid connection state (%d)", btl_endpoint->endpoint_state));
opal_event_del(&btl_endpoint->endpoint_send_event); opal_event_del(&btl_endpoint->endpoint_send_event);

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

@ -2,7 +2,7 @@
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University * Copyright (c) 2004-2007 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -81,7 +81,7 @@ OBJ_CLASS_DECLARATION(mca_btl_tcp_endpoint_t);
void mca_btl_tcp_set_socket_options(int sd); void mca_btl_tcp_set_socket_options(int sd);
void mca_btl_tcp_endpoint_close(mca_btl_base_endpoint_t*); void mca_btl_tcp_endpoint_close(mca_btl_base_endpoint_t*);
int mca_btl_tcp_endpoint_send(mca_btl_base_endpoint_t*, struct mca_btl_tcp_frag_t*); int mca_btl_tcp_endpoint_send(mca_btl_base_endpoint_t*, struct mca_btl_tcp_frag_t*);
bool mca_btl_tcp_endpoint_accept(mca_btl_base_endpoint_t*, struct sockaddr_storage*, int); bool mca_btl_tcp_endpoint_accept(mca_btl_base_endpoint_t*, struct sockaddr*, int);
void mca_btl_tcp_endpoint_shutdown(mca_btl_base_endpoint_t*); void mca_btl_tcp_endpoint_shutdown(mca_btl_base_endpoint_t*);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)

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

@ -2,7 +2,7 @@
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University * Copyright (c) 2004-2007 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -38,13 +38,10 @@
static void mca_btl_tcp_proc_construct(mca_btl_tcp_proc_t* proc); static void mca_btl_tcp_proc_construct(mca_btl_tcp_proc_t* proc);
static void mca_btl_tcp_proc_destruct(mca_btl_tcp_proc_t* proc); static void mca_btl_tcp_proc_destruct(mca_btl_tcp_proc_t* proc);
OBJ_CLASS_INSTANCE( mca_btl_tcp_proc_t,
OBJ_CLASS_INSTANCE(
mca_btl_tcp_proc_t,
opal_list_item_t, opal_list_item_t,
mca_btl_tcp_proc_construct, mca_btl_tcp_proc_construct,
mca_btl_tcp_proc_destruct); mca_btl_tcp_proc_destruct );
void mca_btl_tcp_proc_construct(mca_btl_tcp_proc_t* proc) void mca_btl_tcp_proc_construct(mca_btl_tcp_proc_t* proc)
{ {
@ -104,10 +101,9 @@ mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(ompi_proc_t* ompi_proc)
btl_proc->proc_name = ompi_proc->proc_name; btl_proc->proc_name = ompi_proc->proc_name;
/* add to hash table of all proc instance */ /* add to hash table of all proc instance */
orte_hash_table_set_proc( orte_hash_table_set_proc( &mca_btl_tcp_component.tcp_procs,
&mca_btl_tcp_component.tcp_procs,
&btl_proc->proc_name, &btl_proc->proc_name,
btl_proc); btl_proc );
OPAL_THREAD_UNLOCK(&mca_btl_tcp_component.tcp_lock); OPAL_THREAD_UNLOCK(&mca_btl_tcp_component.tcp_lock);
/* lookup tcp parameters exported by this proc */ /* lookup tcp parameters exported by this proc */
@ -164,9 +160,8 @@ mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(ompi_proc_t* ompi_proc)
* already held. Insert a btl instance into the proc array and assign * already held. Insert a btl instance into the proc array and assign
* it an address. * it an address.
*/ */
int mca_btl_tcp_proc_insert( int mca_btl_tcp_proc_insert( mca_btl_tcp_proc_t* btl_proc,
mca_btl_tcp_proc_t* btl_proc, mca_btl_base_endpoint_t* btl_endpoint )
mca_btl_base_endpoint_t* btl_endpoint)
{ {
size_t i; size_t i;
struct sockaddr_storage endpoint_addr_ss; struct sockaddr_storage endpoint_addr_ss;
@ -186,13 +181,12 @@ int mca_btl_tcp_proc_insert(
btl_endpoint->endpoint_proc = btl_proc; btl_endpoint->endpoint_proc = btl_proc;
btl_proc->proc_endpoints[btl_proc->proc_endpoint_count++] = btl_endpoint; btl_proc->proc_endpoints[btl_proc->proc_endpoint_count++] = btl_endpoint;
/* /*
* Look through the proc instance for an address that is on the * Look through the proc instance for an address that is on the
* directly attached network. If we don't find one, pick the first * directly attached network. If we don't find one, pick the first
* unused address. * unused address.
*/ */
for(i=0; i<btl_proc->proc_addr_count; i++) { for( i = 0; i < btl_proc->proc_addr_count; i++ ) {
mca_btl_tcp_addr_t* endpoint_addr = btl_proc->proc_addrs + i; mca_btl_tcp_addr_t* endpoint_addr = btl_proc->proc_addrs + i;
if(endpoint_addr->addr_inuse != 0) { if(endpoint_addr->addr_inuse != 0) {
continue; continue;
@ -221,7 +215,6 @@ int mca_btl_tcp_proc_insert(
btl_endpoint->endpoint_addr->addr_inuse++; btl_endpoint->endpoint_addr->addr_inuse++;
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
#endif #endif
/* Read: /* Read:
* if we are on the same network, accept. * if we are on the same network, accept.
@ -271,13 +264,12 @@ int mca_btl_tcp_proc_insert(
if( NULL != btl_endpoint->endpoint_addr ) { if( NULL != btl_endpoint->endpoint_addr ) {
btl_endpoint->endpoint_addr->addr_inuse++; btl_endpoint->endpoint_addr->addr_inuse++;
return OMPI_SUCCESS; return OMPI_SUCCESS;
} else { }
/* Bug, FIXME: Once upon a time, there was a lot of /* Bug, FIXME: Once upon a time, there was a lot of
* code in here. I've removed it. There might be better * code in here. I've removed it. There might be better
* approaches. Thomas will show... * approaches. Thomas will show...
*/ */
return OMPI_ERR_UNREACH; return OMPI_ERR_UNREACH;
}
} }
/* /*
@ -326,15 +318,20 @@ mca_btl_tcp_proc_t* mca_btl_tcp_proc_lookup(const orte_process_name_t *name)
} }
/* /*
* loop through all available PTLs for one matching the source address * loop through all available BTLs for one matching the source address
* of the request. * of the request.
*/ */
bool mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t* btl_proc, struct sockaddr_storage* addr, int sd) bool mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t* btl_proc, struct sockaddr* addr, int sd)
{ {
size_t i; size_t i;
OPAL_THREAD_LOCK(&btl_proc->proc_lock); OPAL_THREAD_LOCK(&btl_proc->proc_lock);
for(i=0; i<btl_proc->proc_endpoint_count; i++) { for( i = 0; i < btl_proc->proc_endpoint_count; i++ ) {
mca_btl_base_endpoint_t* btl_endpoint = btl_proc->proc_endpoints[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 ) continue;
if( memcmp( &btl_endpoint->endpoint_addr->addr_inet,
&(((struct sockaddr_in*)addr)->sin_addr),
(AF_INET == addr->sa_family ? sizeof(struct in_addr) : sizeof(struct in6_addr)) ) ) continue;
if(mca_btl_tcp_endpoint_accept(btl_endpoint, addr, sd)) { if(mca_btl_tcp_endpoint_accept(btl_endpoint, addr, sd)) {
OPAL_THREAD_UNLOCK(&btl_proc->proc_lock); OPAL_THREAD_UNLOCK(&btl_proc->proc_lock);
return true; return true;
@ -373,10 +370,10 @@ bool mca_btl_tcp_proc_tosocks(mca_btl_tcp_addr_t* proc_addr,
break; break;
#endif #endif
default: default:
opal_output (0, opal_output( 0, "mca_btl_tcp_proc: unknown af_family received: %d\n",
"mca_btl_tcp_proc: unknown af_family received: %d\n", proc_addr->addr_family );
proc_addr->addr_family);
return false; return false;
} }
return true; return true;
} }

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

@ -68,7 +68,7 @@ mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(ompi_proc_t* ompi_proc);
mca_btl_tcp_proc_t* mca_btl_tcp_proc_lookup(const orte_process_name_t* name); mca_btl_tcp_proc_t* mca_btl_tcp_proc_lookup(const orte_process_name_t* name);
int mca_btl_tcp_proc_insert(mca_btl_tcp_proc_t*, mca_btl_base_endpoint_t*); int mca_btl_tcp_proc_insert(mca_btl_tcp_proc_t*, mca_btl_base_endpoint_t*);
int mca_btl_tcp_proc_remove(mca_btl_tcp_proc_t*, mca_btl_base_endpoint_t*); int mca_btl_tcp_proc_remove(mca_btl_tcp_proc_t*, mca_btl_base_endpoint_t*);
bool mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t*, struct sockaddr_storage*, int); bool mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t*, struct sockaddr*, int);
bool mca_btl_tcp_proc_tosocks(mca_btl_tcp_addr_t*, struct sockaddr_storage*); bool mca_btl_tcp_proc_tosocks(mca_btl_tcp_addr_t*, struct sockaddr_storage*);
/** /**