diff mbox

[2/5] dapl ucm: check for AH caching when destroying via UD extension

Message ID 54347E5A035A054EAE9D05927FB467F977D76B90@ORSMSX101.amr.corp.intel.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Arlin Davis May 22, 2015, 9:43 p.m. UTC
From: Arlin Davis <arlin.r.davis@intel.com>

Signed-off-by: Arlin Davis <arlin.r.davis@intel.com>
---
 dapl/openib_common/ib_extensions.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/dapl/openib_common/ib_extensions.c b/dapl/openib_common/ib_extensions.c
index fc03d9c..25db541 100644
--- a/dapl/openib_common/ib_extensions.c
+++ b/dapl/openib_common/ib_extensions.c
@@ -202,7 +202,6 @@  dapl_extensions(IN DAT_HANDLE dat_handle,
 			status = DAT_ERROR(DAT_INVALID_HANDLE,
 					   DAT_INVALID_HANDLE_EP);
 		else {
-			cm->ah = NULL; /* consumer will free AH */
 			status = dapls_ud_cm_free(ep, cm);
 		}
 		break;
@@ -210,6 +209,7 @@  dapl_extensions(IN DAT_HANDLE dat_handle,
 	case DAT_IB_UD_AH_FREE_OP:
 	{
 		DAT_IB_ADDR_HANDLE *dat_ah;
+		uint16_t lid;
 		int ret;
 
 		dapl_dbg_log(DAPL_DBG_TYPE_RTN,
@@ -222,8 +222,18 @@  dapl_extensions(IN DAT_HANDLE dat_handle,
 			status = DAT_ERROR(DAT_INVALID_HANDLE,
 					   DAT_INVALID_HANDLE_EP);
 		} else {
+			lid = ntohs(((union dcm_addr *)&dat_ah->ia_addr)->ib.lid);
+
+			if (lid > DCM_AH_SPACE) {
+				status = DAT_ERROR(DAT_INVALID_PARAMETER,
+						   DAT_INVALID_ARG2);
+				break;
+			}
+
 			errno = 0;
-			ret = ibv_destroy_ah(dat_ah->ah);
+			if (!((DAPL_EP *)ep)->qp_handle->ah[lid])
+				ret = ibv_destroy_ah(dat_ah->ah);
+
 			status = dapl_convert_errno(errno, "destroy_ah");
 		}
 		break;