[ofa-general] [PATCH 3/4][v2] dapl: add provider vendor revision data in private data with reject

Davis, Arlin R arlin.r.davis at intel.com
Fri Apr 4 16:41:05 PDT 2008


Add 1 byte header containing provider/vendor major revision
to distinguish between consumer and non-consumer rejects.
Validate size of consumer reject privated data.

Signed-off by: Arlin Davis ardavis at ichips.intel.com
---
 dapl/openib_cma/dapl_ib_cm.c   |   39
++++++++++++++++++++++++++++++++-------
 dapl/openib_cma/dapl_ib_util.h |    2 +-
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/dapl/openib_cma/dapl_ib_cm.c b/dapl/openib_cma/dapl_ib_cm.c
index 33f299d..dcdcc5b 100755
--- a/dapl/openib_cma/dapl_ib_cm.c
+++ b/dapl/openib_cma/dapl_ib_cm.c
@@ -45,6 +45,7 @@
 #include "dapl_cr_util.h"
 #include "dapl_name_service.h"
 #include "dapl_ib_util.h"
+#include "dapl_vendor.h"
 #include <sys/poll.h>
 #include <signal.h>
 #include <sys/socket.h>
@@ -79,6 +80,14 @@ static inline uint64_t cpu_to_be64(uint64_t x) {
return x; }
 
 #define PORT_TO_SID(p) ntohs(p)
 
+/* private data header to validate consumer rejects versus abnormal
events */
+struct dapl_pdata_hdr {
+	uint8_t  version;
+};
+static struct dapl_pdata_hdr pdata_hdr = {
+	.version = VN_PROVIDER_MAJOR 
+};
+
 static void dapli_addr_resolve(struct dapl_cm_id *conn)
 {
 	int ret;
@@ -900,6 +909,7 @@ dapls_ib_reject_connection(
 	IN const DAT_PVOID private_data)
 {
     	int ret;
+	int offset = sizeof(struct dapl_pdata_hdr);
 
 	dapl_dbg_log(DAPL_DBG_TYPE_CM,
 		     " reject(cm_handle %p reason %x)\n",
@@ -909,14 +919,29 @@ dapls_ib_reject_connection(
 		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
 			     " reject: invalid handle: reason %d\n",
 			     reason);
-		return DAT_SUCCESS;
+		return DAT_ERROR
(DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_CR);
 	}
-
+    
+        if (private_data_size > 
+		dapls_ib_private_data_size(
+			NULL, IB_MAX_REJ_PDATA_SIZE, cm_handle->hca))
+		return DAT_ERROR(DAT_INVALID_PARAMETER,
DAT_INVALID_ARG3);
+	
+	/* setup pdata_hdr and users data, in CR pdata buffer */
+	dapl_os_memcpy(cm_handle->p_data, &pdata_hdr, offset);
+	if (private_data_size)
+        	dapl_os_memcpy(cm_handle->p_data+offset,
+			       private_data, 
+			       private_data_size);
+	
 	/*
-         * Private data is needed so peer can determine real
application 
-	 * reject from an abnormal application termination
+	 * Always some private data with reject so active peer can
+         * determine real application reject from an abnormal 
+	 * application termination
 	 */
-	ret = rdma_reject(cm_handle->cm_id, NULL, 0);
+	ret = rdma_reject(cm_handle->cm_id, 
+			  cm_handle->p_data, 
+			  offset+private_data_size);
 
 	dapli_destroy_conn(cm_handle);
 	return dapl_convert_errno(ret, "reject");
@@ -1005,7 +1030,7 @@ int dapls_ib_private_data_size(	IN DAPL_PRIVATE
*prd_ptr,
 
         if (hca_ptr->ib_hca_handle->device->transport_type 
 					== IBV_TRANSPORT_IWARP)
-		return(IWARP_MAX_PDATA_SIZE);
+		return(IWARP_MAX_PDATA_SIZE-sizeof(struct
dapl_pdata_hdr));
 
 	switch(conn_op)	{
 
@@ -1016,7 +1041,7 @@ int dapls_ib_private_data_size(	IN DAPL_PRIVATE
*prd_ptr,
 		size = IB_MAX_REP_PDATA_SIZE;
 		break;
 	case DAPL_PDATA_CONN_REJ:
-		size = IB_MAX_REJ_PDATA_SIZE;
+		size = IB_MAX_REJ_PDATA_SIZE-sizeof(struct
dapl_pdata_hdr);
 		break;
 	case DAPL_PDATA_CONN_DREQ:
 		size = IB_MAX_DREQ_PDATA_SIZE;
diff --git a/dapl/openib_cma/dapl_ib_util.h
b/dapl/openib_cma/dapl_ib_util.h
index f35cb9d..370f3b1 100755
--- a/dapl/openib_cma/dapl_ib_util.h
+++ b/dapl/openib_cma/dapl_ib_util.h
@@ -181,7 +181,7 @@ struct dapl_cm_id {
 	struct rdma_conn_param		params;
 	DAT_SOCK_ADDR6			r_addr;
 	int				p_len;
-	unsigned char			p_data[IB_MAX_DREP_PDATA_SIZE];
+	unsigned char			p_data[256]; /* dapl max private
data size */
 };
 
 typedef struct dapl_cm_id	*dp_ib_cm_handle_t;
-- 
1.5.2.5




More information about the general mailing list