[ofw] [PATCH 3/3] uDAPL v2: scm: tighten up socket options to insure similiar behavior on Windows and Linux.

Davis, Arlin R arlin.r.davis at intel.com
Mon Sep 28 15:08:20 PDT 2009


Add IPPROTO_TCP to create socket. Specify device IP address
when binding instead of INADDR_ANY and remove setsocketopt
REUSEADDR on the listen socket to avoid any issues with
portability. Don't want duplicate port bindings.

Signed-off-by: Arlin Davis <arlin.r.davis at intel.com>
---
 dapl/openib_scm/cm.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/dapl/openib_scm/cm.c b/dapl/openib_scm/cm.c
index 87f5446..dae1781 100644
--- a/dapl/openib_scm/cm.c
+++ b/dapl/openib_scm/cm.c
@@ -531,7 +531,7 @@ dapli_socket_connect(DAPL_EP * ep_ptr,
 
 	/* create, connect, sockopt, and exchange QP information */
 	if ((cm_ptr->socket =
-	     socket(AF_INET, SOCK_STREAM, 0)) == DAPL_INVALID_SOCKET) {
+	     socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == DAPL_INVALID_SOCKET) {
 		dapl_os_free(cm_ptr, sizeof(*cm_ptr));
 		return DAT_INSUFFICIENT_RESOURCES;
 	}
@@ -815,7 +815,6 @@ dapli_socket_listen(DAPL_IA * ia_ptr, DAT_CONN_QUAL serviceID, DAPL_SP * sp_ptr)
 {
 	struct sockaddr_in addr;
 	ib_cm_srvc_handle_t cm_ptr = NULL;
-	int opt = 1;
 	DAT_RETURN dat_status = DAT_SUCCESS;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
@@ -831,19 +830,16 @@ dapli_socket_listen(DAPL_IA * ia_ptr, DAT_CONN_QUAL serviceID, DAPL_SP * sp_ptr)
 
 	/* bind, listen, set sockopt, accept, exchange data */
 	if ((cm_ptr->socket =
-	     socket(AF_INET, SOCK_STREAM, 0)) == DAPL_INVALID_SOCKET) {
+	     socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == DAPL_INVALID_SOCKET) {
 		dapl_log(DAPL_DBG_TYPE_ERR, " ERR: listen socket create: %s\n",
 			 strerror(errno));
 		dat_status = DAT_INSUFFICIENT_RESOURCES;
 		goto bail;
 	}
 
-	setsockopt(cm_ptr->socket, SOL_SOCKET, SO_REUSEADDR,
-		   (char *)&opt, sizeof(opt));
-
 	addr.sin_port = htons(serviceID);
 	addr.sin_family = AF_INET;
-	addr.sin_addr.s_addr = INADDR_ANY;
+	addr.sin_addr = ((struct sockaddr_in *) &ia_ptr->hca_ptr->hca_address)->sin_addr;
 
 	if ((bind(cm_ptr->socket, (struct sockaddr *)&addr, sizeof(addr)) < 0)
 	    || (listen(cm_ptr->socket, 128) < 0)) {
-- 
1.5.2.5




More information about the ofw mailing list