void mca_btl_tcp_dump(struct mca_btl_base_module_t* base_btl, struct mca_btl_base_endpoint_t* endpoint, int verbose) { mca_btl_tcp_module_t* btl = (mca_btl_tcp_module_t*)base_btl; mca_btl_base_err("%s TCP %p kernel_id %d\n" #if MCA_BTL_TCP_STATISTICS " | statistics: sent %lu recv %lu\n" #endif /* MCA_BTL_TCP_STATISTICS */ " | latency %u bandwidth %u\n", OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), (void*)btl, btl->tcp_ifkindex, #if MCA_BTL_TCP_STATISTICS btl->tcp_bytes_sent, btl->btl_bytes_recv, #endif /* MCA_BTL_TCP_STATISTICS */ btl->super.btl_latency, btl->super.btl_bandwidth); #if OPAL_ENABLE_DEBUG && WANT_PEER_DUMP if( NULL != endpoint ) { MCA_BTL_TCP_ENDPOINT_DUMP(10, endpoint, false, "TCP"); } else if( verbose ) { opal_list_item_t *item; OPAL_THREAD_LOCK(&btl->tcp_endpoints_mutex); for(item = opal_list_get_first(&btl->tcp_endpoints); item != opal_list_get_end(&btl->tcp_endpoints); item = opal_list_get_next(item)) { MCA_BTL_TCP_ENDPOINT_DUMP(10, (mca_btl_base_endpoint_t*)item, false, "TCP"); } OPAL_THREAD_UNLOCK(&btl->tcp_endpoints_mutex); } #endif /* OPAL_ENABLE_DEBUG && WANT_PEER_DUMP */ }
void mca_btl_tcp_endpoint_dump(mca_btl_base_endpoint_t* btl_endpoint, const char* msg) { char src[64], dst[64], *status; int sndbuf, rcvbuf, nodelay, flags = -1; #if OPAL_ENABLE_IPV6 struct sockaddr_storage inaddr; #else struct sockaddr_in inaddr; #endif opal_socklen_t obtlen; opal_socklen_t addrlen = sizeof(inaddr); opal_list_item_t *item; if( -1 != btl_endpoint->endpoint_sd ) { getsockname(btl_endpoint->endpoint_sd, (struct sockaddr*)&inaddr, &addrlen); #if OPAL_ENABLE_IPV6 { char *address; address = (char *) opal_net_get_hostname((struct sockaddr*) &inaddr); if (NULL != address) { sprintf(src, "%s", address); } } #else sprintf(src, "%s", inet_ntoa(inaddr.sin_addr)); #endif getpeername(btl_endpoint->endpoint_sd, (struct sockaddr*)&inaddr, &addrlen); #if OPAL_ENABLE_IPV6 { char *address; address = (char *) opal_net_get_hostname ((struct sockaddr*) &inaddr); if (NULL != address) { sprintf(dst, "%s", address); } } #else sprintf(dst, "%s", inet_ntoa(inaddr.sin_addr)); #endif if((flags = fcntl(btl_endpoint->endpoint_sd, F_GETFL, 0)) < 0) { BTL_ERROR(("fcntl(F_GETFL) failed: %s (%d)", strerror(opal_socket_errno), opal_socket_errno)); } #if defined(SO_SNDBUF) obtlen = sizeof(sndbuf); if(getsockopt(btl_endpoint->endpoint_sd, SOL_SOCKET, SO_SNDBUF, (char *)&sndbuf, &obtlen) < 0) { BTL_ERROR(("SO_SNDBUF option: %s (%d)", strerror(opal_socket_errno), opal_socket_errno)); } #else sndbuf = -1; #endif #if defined(SO_RCVBUF) obtlen = sizeof(rcvbuf); if(getsockopt(btl_endpoint->endpoint_sd, SOL_SOCKET, SO_RCVBUF, (char *)&rcvbuf, &obtlen) < 0) { BTL_ERROR(("SO_RCVBUF option: %s (%d)", strerror(opal_socket_errno), opal_socket_errno)); } #else rcvbuf = -1; #endif #if defined(TCP_NODELAY) obtlen = sizeof(nodelay); if(getsockopt(btl_endpoint->endpoint_sd, IPPROTO_TCP, TCP_NODELAY, (char *)&nodelay, &obtlen) < 0) { BTL_ERROR(("TCP_NODELAY option: %s (%d)", strerror(opal_socket_errno), opal_socket_errno)); } #else nodelay = 0; #endif } mca_btl_base_err("%s %s: endpoint %p src %s - dst %s nodelay %d sndbuf %d rcvbuf %d flags %08x\n", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), msg, (void*)btl_endpoint, src, dst, nodelay, sndbuf, rcvbuf, flags); switch(btl_endpoint->endpoint_state) { case MCA_BTL_TCP_CONNECTING: status = "connecting"; break; case MCA_BTL_TCP_CONNECT_ACK: status = "connect ack"; break; case MCA_BTL_TCP_CLOSED: status = "closed"; break; case MCA_BTL_TCP_FAILED: status = "failed"; break; case MCA_BTL_TCP_CONNECTED: status = "connected"; break; default: status = "undefined"; break; } mca_btl_base_err("%s | [socket %d] [state %s] (nbo %s) (retries %u)\n" #if MCA_BTL_TCP_ENDPOINT_CACHE "\tcache %p length %lu pos %ld\n" #endif /* MCA_BTL_TCP_ENDPOINT_CACHE */ "\tpending: send %p recv %p\n", msg, btl_endpoint->endpoint_sd, status, (btl_endpoint->endpoint_nbo ? "true" : "false"), btl_endpoint->endpoint_retries, #if MCA_BTL_TCP_ENDPOINT_CACHE btl_endpoint->endpoint_cache, btl_endpoint->endpoint_cache_length, btl_endpoint->endpoint_cache_pos - btl_endpoint->endpoint_cache, #endif /* MCA_BTL_TCP_ENDPOINT_CACHE */ (void*)btl_endpoint->endpoint_send_frag, (void*)btl_endpoint->endpoint_recv_frag ); for(item = opal_list_get_first(&btl_endpoint->endpoint_frags); item != opal_list_get_end(&btl_endpoint->endpoint_frags); item = opal_list_get_next(item)) { mca_btl_tcp_dump_frag( (mca_btl_tcp_frag_t*)item, " | send" ); } }