From 0a078b5a237122d7bc869253d892376637e379ea Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Fri, 1 Jun 2018 16:15:54 -0700 Subject: [PATCH] qcacld-3.0: Fix HDD WPA/RSN IE layering violation Currently HDD is directly calling csr_roam_get_wpa_rsn_req_ie() and csr_roam_get_wpa_rsn_rsp_ie(). That is a layering violation since HDD should be calling SME APIs; CSR APIs are meant to be called by SME. And SME already exposes two APIs which, in turn, call those CSR APIs. However those SME APIs, sme_roam_get_security_req_ie() and sme_roam_get_security_rsp_ie(), are defined to take an extra secType parameter which is then unused. To clean up this mess modify the SME APIs to have the same naming and parameters as the CSR APIs and update HDD to call the SME APIs. Change-Id: I0ba2f056e089818ab04a8d421e3d8c571e312831 CRs-Fixed: 2254949 --- core/hdd/src/wlan_hdd_assoc.c | 6 +-- core/sme/inc/sme_api.h | 45 +++++++++++++++++++--- core/sme/src/common/sme_api.c | 70 ++++++++++------------------------- 3 files changed, 62 insertions(+), 59 deletions(-) diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c index 475ffb830c94..db61cb510a7b 100644 --- a/core/hdd/src/wlan_hdd_assoc.c +++ b/core/hdd/src/wlan_hdd_assoc.c @@ -3151,13 +3151,13 @@ hdd_association_completion_handler(struct hdd_adapter *adapter, * wpa supplicant expecting WPA/RSN IE in * connect result. */ - csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX + sme_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX (adapter), adapter->session_id, &reqRsnLength, reqRsnIe); - csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX + sme_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX (adapter), adapter->session_id, &rspRsnLength, @@ -3220,7 +3220,7 @@ hdd_association_completion_handler(struct hdd_adapter *adapter, * in case of reassociation also need to indicate it to * supplicant. */ - csr_roam_get_wpa_rsn_req_ie( + sme_roam_get_wpa_rsn_req_ie( WLAN_HDD_GET_HAL_CTX(adapter), adapter->session_id, &reqRsnLength, reqRsnIe); diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 952c2590a5d0..366caa1ddd8a 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -417,12 +417,45 @@ void sme_get_pmk_info(tHalHandle hal, uint8_t session_id, QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId, uint8_t *pPSK_PMK, size_t pmk_len); #endif -QDF_STATUS sme_roam_get_security_req_ie(tHalHandle hHal, uint8_t sessionId, - uint32_t *pLen, uint8_t *pBuf, - eCsrSecurityType secType); -QDF_STATUS sme_roam_get_security_rsp_ie(tHalHandle hHal, uint8_t sessionId, - uint32_t *pLen, uint8_t *pBuf, - eCsrSecurityType secType); + +/** + * sme_roam_get_wpa_rsn_req_ie() - Retrieve WPA/RSN Request IE + * @hal: HAL handle + * @session_id: ID of the specific session + * @len: Caller allocated memory that has the length of @buf as input. + * Upon returned, @len has the length of the IE store in @buf + * @buf: Caller allocated memory that contain the IE field, if any, + * upon return + * + * A wrapper function to request CSR to return the WPA or RSN IE CSR + * passes to PE to JOIN request or START_BSS request + * This is a synchronous call. + * + * Return: QDF_STATUS - when fail, it usually means the buffer allocated is not + * big enough + */ +QDF_STATUS sme_roam_get_wpa_rsn_req_ie(tHalHandle hal, uint8_t session_id, + uint32_t *len, uint8_t *buf); + +/** + * sme_roam_get_wpa_rsn_rsp_ie() - Retrieve WPA/RSN Response IE + * @hal: HAL handle + * @session_id: ID of the specific session + * @len: Caller allocated memory that has the length of @buf as input. + * Upon returned, @len has the length of the IE store in @buf + * @buf: Caller allocated memory that contain the IE field, if any, + * upon return + * + * A wrapper function to request CSR to return the WPA or RSN IE CSR + * passes to PE to JOIN request or START_BSS request + * This is a synchronous call. + * + * Return: QDF_STATUS - when fail, it usually means the buffer allocated is not + * big enough + */ +QDF_STATUS sme_roam_get_wpa_rsn_rsp_ie(tHalHandle hal, uint8_t session_id, + uint32_t *len, uint8_t *buf); + uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId); QDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId, uint32_t *pNum, diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 036ea4af7558..c025c3456dc1 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -3648,73 +3648,43 @@ QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId, return status; } #endif -/* - * sme_roam_get_security_req_ie() - - * A wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR - * passes to PE to JOIN request or START_BSS request - * This is a synchronous call. - * - * pLen - caller allocated memory that has the length of pBuf as input. - * Upon returned, *pLen has the needed or IE length in pBuf. - * pBuf - Caller allocated memory that contain the IE field, if any, - * upon return - * secType - Specifies whether looking for WPA/WPA2/WAPI IE - * Return QDF_STATUS - when fail, it usually means the buffer allocated is not - * big enough - */ -QDF_STATUS sme_roam_get_security_req_ie(tHalHandle hHal, uint8_t sessionId, - uint32_t *pLen, uint8_t *pBuf, - eCsrSecurityType secType) -{ - QDF_STATUS status = QDF_STATUS_E_FAILURE; - tpAniSirGlobal pMac = PMAC_STRUCT(hHal); - status = sme_acquire_global_lock(&pMac->sme); +QDF_STATUS sme_roam_get_wpa_rsn_req_ie(tHalHandle hal, uint8_t session_id, + uint32_t *len, uint8_t *buf) +{ + QDF_STATUS status; + tpAniSirGlobal mac = PMAC_STRUCT(hal); + + status = sme_acquire_global_lock(&mac->sme); if (QDF_IS_STATUS_SUCCESS(status)) { - if (CSR_IS_SESSION_VALID(pMac, sessionId)) - status = csr_roam_get_wpa_rsn_req_ie(hHal, sessionId, - pLen, pBuf); + if (CSR_IS_SESSION_VALID(mac, session_id)) + status = csr_roam_get_wpa_rsn_req_ie(mac, session_id, + len, buf); else status = QDF_STATUS_E_INVAL; - sme_release_global_lock(&pMac->sme); + sme_release_global_lock(&mac->sme); } return status; } -/* - * sme_roam_get_security_rsp_ie() - - * A wrapper function to request CSR to return the WPA or RSN or - * WAPI IE from the beacon or probe rsp if connected - * This is a synchronous call. - * - * pLen - caller allocated memory that has the length of pBuf as input. - * Upon returned, *pLen has the needed or IE length in pBuf. - * pBuf - Caller allocated memory that contain the IE field, if any, - * upon return - * secType - Specifies whether looking for WPA/WPA2/WAPI IE - * Return QDF_STATUS - when fail, it usually means the buffer allocated is not - * big enough - */ -QDF_STATUS sme_roam_get_security_rsp_ie(tHalHandle hHal, uint8_t sessionId, - uint32_t *pLen, uint8_t *pBuf, - eCsrSecurityType secType) +QDF_STATUS sme_roam_get_wpa_rsn_rsp_ie(tHalHandle hal, uint8_t session_id, + uint32_t *len, uint8_t *buf) { - QDF_STATUS status = QDF_STATUS_E_FAILURE; - tpAniSirGlobal pMac = PMAC_STRUCT(hHal); + QDF_STATUS status; + tpAniSirGlobal mac = PMAC_STRUCT(hal); - status = sme_acquire_global_lock(&pMac->sme); + status = sme_acquire_global_lock(&mac->sme); if (QDF_IS_STATUS_SUCCESS(status)) { - if (CSR_IS_SESSION_VALID(pMac, sessionId)) - status = csr_roam_get_wpa_rsn_rsp_ie(pMac, sessionId, - pLen, pBuf); + if (CSR_IS_SESSION_VALID(mac, session_id)) + status = csr_roam_get_wpa_rsn_rsp_ie(mac, session_id, + len, buf); else status = QDF_STATUS_E_INVAL; - sme_release_global_lock(&pMac->sme); + sme_release_global_lock(&mac->sme); } return status; - } /*