From 3fa5cba537c9bbf41ebbcc5d0bf5221c3295e201 Mon Sep 17 00:00:00 2001 From: Liangwei Dong Date: Mon, 16 Jul 2018 06:41:55 -0400 Subject: [PATCH] qcacld-3.0: Limit concurrency of STA(WAPI) When STA role is coexisting with other sessions(P2P, SAP or IBSS), WAPI encryption mode is not allowed. Add a new API to check if the connection/start request should be rejected when: 1) A STA with WAPI encryption is to be connected while there is at least one concurrent session already running. 2) A new session is to be started while there is already a STA connection with WAPI encryption enabled. Change-Id: Id3cc90a63a1b502a3a0783ebbc1af33f96620559 CRs-Fixed: 2271280 --- core/hdd/src/wlan_hdd_cfg80211.c | 23 ++++++++++++++--------- core/hdd/src/wlan_hdd_main.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 52bbede1aed5..99ff4b8dc254 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -19606,7 +19606,20 @@ static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy, return -EALREADY; } - /* Check for max concurrent connections after doing disconnect if any */ + /*initialise security parameters */ + status = wlan_hdd_cfg80211_set_privacy(adapter, req); + + if (status < 0) { + hdd_err("Failed to set security params"); + return status; + } + + /* + * Check for max concurrent connections after doing disconnect if any, + * must be called after the invocation of wlan_hdd_cfg80211_set_privacy + * so privacy is already set for the current adapter before it's + * checked against concurrency. + */ if (req->channel) { bool ok = false; @@ -19659,14 +19672,6 @@ static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy, } } - /*initialise security parameters */ - status = wlan_hdd_cfg80211_set_privacy(adapter, req); - - if (0 > status) { - hdd_err("Failed to set security params"); - return status; - } - if (req->channel) channel = req->channel->hw_value; else diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 72891032da3b..5d51cb7e6df9 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -2658,6 +2658,34 @@ static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) } #endif +#ifdef FEATURE_WLAN_WAPI +/** + * hdd_wapi_security_sta_exist() - return wapi security sta exist or not + * + * This API returns the wapi security station exist or not + * + * Return: true - wapi security station exist + */ +static bool hdd_wapi_security_sta_exist(void) +{ + struct hdd_adapter *adapter = NULL; + struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + + hdd_for_each_adapter(hdd_ctx, adapter) { + if ((adapter->device_mode == QDF_STA_MODE) && + adapter->wapi_info.wapi_mode && + (adapter->wapi_info.wapi_auth_mode != WAPI_AUTH_MODE_OPEN)) + return true; + } + return false; +} +#else +static bool hdd_wapi_security_sta_exist(void) +{ + return false; +} +#endif + #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) @@ -2680,6 +2708,7 @@ static void hdd_register_policy_manager_callback( { struct policy_mgr_hdd_cbacks hdd_cbacks; + qdf_mem_zero(&hdd_cbacks, sizeof(hdd_cbacks)); hdd_cbacks.sap_restart_chan_switch_cb = hdd_sap_restart_chan_switch_cb; hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = @@ -2687,7 +2716,8 @@ static void hdd_register_policy_manager_callback( hdd_cbacks.get_mode_for_non_connected_vdev = wlan_hdd_get_mode_for_non_connected_vdev; hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; - + hdd_cbacks.hdd_wapi_security_sta_exist = + hdd_wapi_security_sta_exist; if (QDF_STATUS_SUCCESS != policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { hdd_err("HDD callback registration with policy manager failed");