From 27f2d2ede8ed284fd07456724fb463b8f2d1657e Mon Sep 17 00:00:00 2001 From: bings Date: Tue, 2 Jun 2020 18:16:48 +0800 Subject: [PATCH] qcacld-3.0: Set correct wep key for sap mode When wep_default_key is not set as 0 in hostapd.conf, wep key with key id 0 should not be sent to FW when new station is connected. Wep key with key id specified in hostapd.conf should be sent to FW. To fix this issue, wep default key id should be saved for sap mode. When reference station is connected, set default key id related key to FW with TX_USAGE flag. Change-Id: Ic13e311593154911ee21db5172188c7037f429a3 CRs-Fixed: 2700441 --- core/hdd/src/wlan_hdd_cfg80211.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 14a0037ba1..d68d78fafa 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -17375,7 +17375,7 @@ static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); struct hdd_context *hdd_ctx; struct qdf_mac_addr bssid = QDF_MAC_ADDR_BCAST_INIT; - struct hdd_station_ctx *sta_ctx; + struct hdd_ap_ctx *ap_ctx; struct wlan_crypto_key *crypto_key; int ret; QDF_STATUS status; @@ -17411,21 +17411,11 @@ static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, hdd_err("Invalid NULL key info"); return -EINVAL; } - hdd_debug("unicast %d, cipher %d", unicast, crypto_key->cipher_type); + hdd_debug("unicast %d, multicast %d cipher %d", + unicast, multicast, crypto_key->cipher_type); if (!IS_WEP_CIPHER(crypto_key->cipher_type)) return 0; - sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); - if (unicast) - status = - wlan_cfg80211_set_default_key(adapter->vdev, key_index, - &sta_ctx->conn_info.bssid); - else - status = wlan_cfg80211_set_default_key(adapter->vdev, key_index, - &bssid); - if (QDF_STATUS_SUCCESS != status) { - hdd_err("ret fail status %d", ret); - return -EINVAL; - } + if ((adapter->device_mode == QDF_STA_MODE) || (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { ret = @@ -17437,6 +17427,18 @@ static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, crypto_key->cipher_type); } + if (adapter->device_mode == QDF_SAP_MODE || + adapter->device_mode == QDF_P2P_GO_MODE) { + status = wlan_cfg80211_set_default_key(adapter->vdev, key_index, + &bssid); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("ret fail status %d", ret); + return -EINVAL; + } + ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); + ap_ctx->wep_def_key_idx = key_index; + } + return ret; }