From add284b8800cb5edca710615e38c2abaf74f5c8b Mon Sep 17 00:00:00 2001 From: Arun Kumar Khandavalli Date: Wed, 23 Oct 2019 12:27:39 +0530 Subject: [PATCH] qcacld-3.0: check for duplicate session before vdev create Check for any duplicate peer with the same mac address before the vdev is created. Change-Id: Ie6d71b7b2892ab2ac6e8bfb37c99f20f0854c2f2 CRs-Fixed: 2555932 --- core/hdd/src/wlan_hdd_main.c | 7 ++++ core/sme/inc/sme_api.h | 12 +++++++ core/sme/src/common/sme_api.c | 64 +++++++++++++++++++++++------------ 3 files changed, 61 insertions(+), 22 deletions(-) diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 687ff0bc6377..a530c45949b7 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -4497,6 +4497,13 @@ int hdd_vdev_create(struct hdd_adapter *adapter) /* do vdev create via objmgr */ hdd_ctx = WLAN_HDD_GET_CTX(adapter); + status = sme_check_for_duplicate_session(hdd_ctx->mac_handle, + adapter->mac_addr.bytes); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Duplicate session is existing with same mac address"); + errno = qdf_status_to_os_return(status); + return errno; + } errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->pdev, adapter); if (errno) { hdd_err("failed to create objmgr vdev: %d", errno); diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 12c7ca7a98ed..3f190856b38c 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -3941,4 +3941,16 @@ uint16_t sme_get_full_roam_scan_period_global(mac_handle_t mac_handle); QDF_STATUS sme_get_full_roam_scan_period(mac_handle_t mac_handle, uint8_t vdev_id, uint32_t *full_roam_scan_period); + +/** + * sme_check_for_duplicate_session() - check for duplicate session + * @mac_handle: Opaque handle to the MAC context + * @peer_addr: Peer device mac address + * + * Check for duplicate mac address is available on other vdev. + * + * Return: QDF_STATUS + */ +QDF_STATUS sme_check_for_duplicate_session(mac_handle_t mac_handle, + uint8_t *peer_addr); #endif /* #if !defined( __SME_API_H ) */ diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 4cba470c8143..7a12549feec5 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -4504,10 +4504,7 @@ QDF_STATUS sme_create_vdev(mac_handle_t mac_handle, { QDF_STATUS status = QDF_STATUS_E_INVAL; struct mac_context *mac_ctx = MAC_CONTEXT(mac_handle); - struct cdp_pdev *pdev; - ol_txrx_peer_handle peer; - u8 peer_id, vdev_id; - void *soc = cds_get_context(QDF_MODULE_ID_SOC); + uint8_t vdev_id; u8 *mac_addr; vdev_id = wlan_vdev_get_id(params->vdev); @@ -4515,28 +4512,13 @@ QDF_STATUS sme_create_vdev(mac_handle_t mac_handle, sme_debug("vdev_id %d addr:%pM", vdev_id, mac_addr); - pdev = cds_get_context(QDF_MODULE_ID_TXRX); - - if (!pdev) { - sme_err("Failed to get pdev handler"); - return status; - } - status = sme_acquire_global_lock(&mac_ctx->sme); if (QDF_IS_STATUS_ERROR(status)) return status; - peer = cdp_peer_find_by_addr(soc, pdev, - mac_addr, - &peer_id); - if (peer) { - sme_err("Peer=%d exist with same MAC", peer_id); - status = QDF_STATUS_E_INVAL; - } else { - status = csr_create_vdev(mac_ctx, params->vdev, params); - if (QDF_IS_STATUS_SUCCESS(status)) - status = mlme_vdev_self_peer_create(params->vdev); - } + status = csr_create_vdev(mac_ctx, params->vdev, params); + if (QDF_IS_STATUS_SUCCESS(status)) + status = mlme_vdev_self_peer_create(params->vdev); sme_release_global_lock(&mac_ctx->sme); MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION, @@ -16188,3 +16170,41 @@ sme_get_full_roam_scan_period(mac_handle_t mac_handle, uint8_t vdev_id, return status; } + +QDF_STATUS sme_check_for_duplicate_session(mac_handle_t mac_handle, + uint8_t *peer_addr) +{ + QDF_STATUS status = QDF_STATUS_E_INVAL; + struct cdp_pdev *pdev; + ol_txrx_peer_handle peer; + uint8_t peer_id; + void *soc = cds_get_context(QDF_MODULE_ID_SOC); + struct mac_context *mac_ctx = MAC_CONTEXT(mac_handle); + + if (!soc) { + sme_err("Failed to get soc handle"); + return QDF_STATUS_E_INVAL; + } + + pdev = cds_get_context(QDF_MODULE_ID_TXRX); + if (!pdev) { + sme_err("Failed to get pdev handler"); + return QDF_STATUS_E_INVAL; + } + + if (QDF_STATUS_SUCCESS != sme_acquire_global_lock(&mac_ctx->sme)) + return status; + + peer = cdp_peer_find_by_addr(soc, pdev, + peer_addr, + &peer_id); + if (peer) { + sme_err("Peer=%d exist with same MAC", peer_id); + status = QDF_STATUS_E_EXISTS; + } else { + status = QDF_STATUS_SUCCESS; + } + sme_release_global_lock(&mac_ctx->sme); + + return status; +}