diff options
author | Srikanth Marepalli <marepall@codeaurora.org> | 2020-06-03 23:33:12 +0530 |
---|---|---|
committer | nshrivas <nshrivas@codeaurora.org> | 2020-06-05 22:05:19 -0700 |
commit | 54e67b70284d8ee9e18ab18f24eab64bbc5988b6 (patch) | |
tree | 96a2ce565a85c8dec87680e32f150cdb09c5f182 /core/sme | |
parent | 145394874ccf033417a03381c3c805e689e64b47 (diff) | |
download | qcacld-54e67b70284d8ee9e18ab18f24eab64bbc5988b6.tar.gz |
qcacld-3.0: Delete older PMK of all APs which have the same PMK
With Commit: I95881db229d5193cbdc22c5f30e1375b3892fbd4
the crypto changes went in to handle the PMK cache deletion. But
the crypto module is disabled in 2.0.5.
This change is to take in the respective changes of 2.0.3.
Change-Id: Idd7ef8ec05db89d83b8f5e8e6e19332714b00a4c
CRs-Fixed: 2702864
Diffstat (limited to 'core/sme')
-rw-r--r-- | core/sme/src/csr/csr_api_roam.c | 110 | ||||
-rw-r--r-- | core/sme/src/csr/csr_inside_api.h | 3 |
2 files changed, 75 insertions, 38 deletions
diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c index e441ac1a06..33a06c1388 100644 --- a/core/sme/src/csr/csr_api_roam.c +++ b/core/sme/src/csr/csr_api_roam.c @@ -15313,6 +15313,66 @@ void csr_clear_sae_single_pmk(struct mac_context *mac, } #endif +void csr_roam_del_pmk_cache_entry(struct csr_roam_session *session, + tPmkidCacheInfo *cached_pmksa) +{ + u32 curr_idx; + u8 del_pmk[CSR_RSN_MAX_PMK_LEN] = {0}; + u32 i, del_idx; + + /* copy the PMK of matched BSSID */ + qdf_mem_copy(del_pmk, cached_pmksa->pmk, cached_pmksa->pmk_len); + + /* Search for matching PMK in session PMK cache */ + for (del_idx = 0; del_idx != session->NumPmkidCache; del_idx++) { + cached_pmksa = &session->PmkidCacheInfo[del_idx]; + if (cached_pmksa->pmk_len && (!qdf_mem_cmp + (cached_pmksa->pmk, del_pmk, cached_pmksa->pmk_len))) { + /* Clear this - matched entry */ + qdf_mem_zero(cached_pmksa, sizeof(tPmkidCacheInfo)); + + /* Match Found, Readjust the other entries */ + curr_idx = session->curr_cache_idx; + if (del_idx < curr_idx) { + for (i = del_idx; i < (curr_idx - 1); i++) { + qdf_mem_copy(&session-> + PmkidCacheInfo[i], + &session-> + PmkidCacheInfo[i + 1], + sizeof(tPmkidCacheInfo)); + } + + session->curr_cache_idx--; + qdf_mem_zero(&session->PmkidCacheInfo + [session->curr_cache_idx], + sizeof(tPmkidCacheInfo)); + } else if (del_idx > curr_idx) { + for (i = del_idx; i > (curr_idx); i--) { + qdf_mem_copy(&session-> + PmkidCacheInfo[i], + &session-> + PmkidCacheInfo[i - 1], + sizeof(tPmkidCacheInfo)); + } + + qdf_mem_zero(&session->PmkidCacheInfo + [session->curr_cache_idx], + sizeof(tPmkidCacheInfo)); + } + + /* Decrement the count since an entry is been deleted */ + session->NumPmkidCache--; + sme_debug("PMKID at index=%d deleted, current index=%d cache count=%d", + del_idx, session->curr_cache_idx, + session->NumPmkidCache); + /* As we re-adjusted entries by one position search + * again from current index + */ + del_idx--; + } + } +} + QDF_STATUS csr_roam_del_pmkid_from_cache(struct mac_context *mac, uint32_t sessionId, tPmkidCacheInfo *pmksa, @@ -15321,9 +15381,7 @@ QDF_STATUS csr_roam_del_pmkid_from_cache(struct mac_context *mac, struct csr_roam_session *pSession = CSR_GET_SESSION(mac, sessionId); bool fMatchFound = false; uint32_t Index; - uint32_t curr_idx; tPmkidCacheInfo *cached_pmksa; - uint32_t i; if (!pSession) { sme_err("session %d not found", sessionId); @@ -15367,47 +15425,14 @@ QDF_STATUS csr_roam_del_pmkid_from_cache(struct mac_context *mac, fMatchFound = 1; if (fMatchFound) { - /* Clear this - matched entry */ - qdf_mem_zero(cached_pmksa, - sizeof(tPmkidCacheInfo)); + /* Delete the matched PMK cache entry */ + csr_roam_del_pmk_cache_entry(pSession, cached_pmksa); break; } } - if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) { + if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) sme_debug("No such PMKSA entry exists"); - return QDF_STATUS_SUCCESS; - } - - /* Match Found, Readjust the other entries */ - curr_idx = pSession->curr_cache_idx; - if (Index < curr_idx) { - for (i = Index; i < (curr_idx - 1); i++) { - qdf_mem_copy(&pSession->PmkidCacheInfo[i], - &pSession->PmkidCacheInfo[i + 1], - sizeof(tPmkidCacheInfo)); - } - - pSession->curr_cache_idx--; - qdf_mem_zero(&pSession->PmkidCacheInfo - [pSession->curr_cache_idx], - sizeof(tPmkidCacheInfo)); - } else if (Index > curr_idx) { - for (i = Index; i > (curr_idx); i--) { - qdf_mem_copy(&pSession->PmkidCacheInfo[i], - &pSession->PmkidCacheInfo[i - 1], - sizeof(tPmkidCacheInfo)); - } - - qdf_mem_zero(&pSession->PmkidCacheInfo - [pSession->curr_cache_idx], - sizeof(tPmkidCacheInfo)); - } - - /* Decrement the count since an entry has been deleted */ - pSession->NumPmkidCache--; - sme_debug("PMKID at index=%d deleted, current index=%d cache count=%d", - Index, pSession->curr_cache_idx, pSession->NumPmkidCache); return QDF_STATUS_SUCCESS; } @@ -23014,6 +23039,15 @@ static QDF_STATUS csr_process_roam_sync_callback(struct mac_context *mac_ctx, sme_debug("PMKID Not found in cache for " QDF_MAC_ADDR_STR, QDF_MAC_ADDR_ARRAY(pmkid_cache->BSSID.bytes)); if (roam_synch_data->pmk_len) { + qdf_mem_copy(pmkid_cache->PMKID, + roam_synch_data->pmkid, PMKID_LEN); + qdf_mem_copy(pmkid_cache->pmk, + roam_synch_data->pmk, + roam_synch_data->pmk_len); + pmkid_cache->pmk_len = roam_synch_data->pmk_len; + + csr_update_pmk_cache(session, pmkid_cache); + pmksa = qdf_mem_malloc(sizeof(*pmksa)); if (!pmksa) { status = QDF_STATUS_E_NOMEM; diff --git a/core/sme/src/csr/csr_inside_api.h b/core/sme/src/csr/csr_inside_api.h index 65813ad381..c3431b4a11 100644 --- a/core/sme/src/csr/csr_inside_api.h +++ b/core/sme/src/csr/csr_inside_api.h @@ -839,6 +839,9 @@ QDF_STATUS csr_roam_del_pmkid_from_cache(struct mac_context *mac, tPmkidCacheInfo *pmksa, bool flush_cache); +void csr_roam_del_pmk_cache_entry(struct csr_roam_session *session, + tPmkidCacheInfo *cached_pmksa); + #if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) /** * csr_clear_sae_single_pmk - API to clear single_pmk_info cache |