Browse Source

qcacld-3.0: Fix to encrypt broadcast frames

qcacld-2.0 to qcacld-3.0 propagation

Currently, In SAP mode due to incorrect wep key
index broadcast frames are not encrypted.

Fix is to make sure to update default index for
BSS(group) key.

Change-Id: I328855decbad20dbd88b48022e466e4f78f5d722
CRs-Fixed: 932749
Masti, Narayanraddi 8 years ago
parent
commit
ab712a7a63

+ 5 - 0
core/hdd/src/wlan_hdd_cfg80211.c

@@ -9242,6 +9242,11 @@ static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy,
 				WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
 			pAPCtx->wepKey[key_index].keyDirection =
 				eSIR_TX_DEFAULT;
+			hdd_info("key index passed for sme_roam_set_default_key_index %d",
+				key_index);
+			sme_roam_set_default_key_index(
+				WLAN_HDD_GET_HAL_CTX(pAdapter),
+				pAdapter->sessionId, key_index);
 		}
 	}
 

+ 1 - 0
core/mac/src/include/sir_params.h

@@ -628,6 +628,7 @@ typedef struct sSirMbMsgP2p {
 #define SIR_HAL_NDP_INDICATION              (SIR_HAL_ITC_MSG_TYPES_BEGIN + 355)
 #define SIR_HAL_NDP_CONFIRM                 (SIR_HAL_ITC_MSG_TYPES_BEGIN + 356)
 #define SIR_HAL_NDP_END_IND                 (SIR_HAL_ITC_MSG_TYPES_BEGIN + 357)
+#define SIR_HAL_UPDATE_WEP_DEFAULT_KEY      (SIR_HAL_ITC_MSG_TYPES_BEGIN + 358)
 
 #define SIR_HAL_POWER_DBG_CMD               (SIR_HAL_ITC_MSG_TYPES_BEGIN + 347)
 

+ 13 - 0
core/sme/inc/csr_api.h

@@ -1599,6 +1599,19 @@ struct tagCsrDelStaParams {
 	uint8_t subtype;
 };
 
+/**
+ * struct wep_update_default_key_idx: wep default key index structure
+ * @session_id: session ID for the connection session
+ * @default_idx: default key index for wep
+ *
+ * structure includes sesssion id for connection and default key
+ * index used for wep
+ */
+struct wep_update_default_key_idx {
+	uint8_t session_id;
+	uint8_t default_idx;
+};
+
 /*
  * NOTE: p2 is the second context pass in for the caller
  * NOTE: what if callback is called before requester gets the scanId??

+ 2 - 0
core/sme/inc/sme_api.h

@@ -1154,4 +1154,6 @@ QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
 
 void sme_get_vdev_type_nss(tHalHandle hal, enum tQDF_ADAPTER_MODE dev_mode,
 		uint8_t *nss_2g, uint8_t *nss_5g);
+QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
+					  uint8_t default_idx);
 #endif /* #if !defined( __SME_API_H ) */

+ 44 - 0
core/sme/src/common/sme_api.c

@@ -5096,6 +5096,50 @@ QDF_STATUS sme_roam_set_key(tHalHandle hal,  uint8_t session_id,
 	return status;
 }
 
+/**
+ * sme_roam_set_default_key_index - To set default wep key idx
+ * @hal: pointer to hal handler
+ * @session_id: session id
+ * @default_idx: default wep key index
+ *
+ * This function prepares a message and post to WMA to set wep default
+ * key index
+ *
+ * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
+ */
+QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
+					  uint8_t default_idx)
+{
+	cds_msg_t msg;
+	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
+	struct wep_update_default_key_idx *update_key;
+
+	update_key = qdf_mem_malloc(sizeof(*update_key));
+	if (!update_key) {
+		sms_log(mac_ctx, LOGE,
+			FL("Failed to allocate memory for update key"));
+		return QDF_STATUS_E_NOMEM;
+	}
+
+	update_key->session_id = session_id;
+	update_key->default_idx = default_idx;
+
+	msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
+	msg.reserved = 0;
+	msg.bodyptr = (void *)update_key;
+
+	if (QDF_STATUS_SUCCESS !=
+	    cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
+		sms_log(mac_ctx, LOGE,
+			FL("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA"));
+		qdf_mem_free(update_key);
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+
+
 /* ---------------------------------------------------------------------------
     \fn sme_get_rssi
     \brief a wrapper function that client calls to register a callback to get

+ 2 - 0
core/wma/inc/wma.h

@@ -864,6 +864,7 @@ typedef struct {
  * @rx_streams: number of rx streams can be used by the vdev
  * @chain_mask: chain mask can be used by the vdev
  * @mac_id: the mac on which vdev is on
+ * @wep_default_key_idx: wep default index for group key
  *
  * It stores parameters per vdev in wma.
  */
@@ -940,6 +941,7 @@ struct wma_txrx_node {
 	uint8_t nss_2g;
 	uint8_t nss_5g;
 	bool p2p_lo_in_progress;
+	uint8_t wep_default_key_idx;
 };
 
 #if defined(QCA_WIFI_FTM)

+ 1 - 0
core/wma/inc/wma_types.h

@@ -471,6 +471,7 @@
 #define WDA_BPF_SET_INSTRUCTIONS_REQ         SIR_HAL_BPF_SET_INSTRUCTIONS_REQ
 
 #define WMA_SET_PDEV_IE_REQ                  SIR_HAL_SET_PDEV_IE_REQ
+#define WMA_UPDATE_WEP_DEFAULT_KEY           SIR_HAL_UPDATE_WEP_DEFAULT_KEY
 /* Bit 6 will be used to control BD rate for Management frames */
 #define HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME 0x40
 

+ 24 - 0
core/wma/src/wma_main.c

@@ -5216,6 +5216,25 @@ void wma_send_flush_logs_to_fw(tp_wma_handle wma_handle)
 		WMA_LOGE("Failed to start the log completion timer");
 }
 
+/**
+ * wma_update_wep_default_key - To update default key id
+ * @wma: pointer to wma handler
+ * @update_def_key: pointer to wep_update_default_key_idx
+ *
+ * This function makes a copy of default key index to txrx node
+ *
+ * Return: Success
+ */
+static QDF_STATUS wma_update_wep_default_key(tp_wma_handle wma,
+			struct wep_update_default_key_idx *update_def_key)
+{
+	struct wma_txrx_node *iface =
+		&wma->interfaces[update_def_key->session_id];
+	iface->wep_default_key_idx = update_def_key->default_idx;
+
+	return QDF_STATUS_SUCCESS;
+}
+
 /**
  * wma_mc_process_msg() - process wma messages and call appropriate function.
  * @cds_context: cds context
@@ -6010,6 +6029,11 @@ QDF_STATUS wma_mc_process_msg(void *cds_context, cds_msg_t *msg)
 					    msg->bodyptr);
 		qdf_mem_free(msg->bodyptr);
 		break;
+	case WMA_UPDATE_WEP_DEFAULT_KEY:
+		wma_update_wep_default_key(wma_handle,
+			(struct wep_update_default_key_idx *)msg->bodyptr);
+		qdf_mem_free(msg->bodyptr);
+		break;
 	default:
 		WMA_LOGD("unknow msg type %x", msg->type);
 		/* Do Nothing? MSG Body should be freed at here */

+ 5 - 0
core/wma/src/wma_mgmt.c

@@ -1766,6 +1766,11 @@ static void wma_set_ibsskey_helper(tp_wma_handle wma_handle,
 	     key_info->encType == eSIR_ED_WEP104)) {
 		wma_read_cfg_wepkey(wma_handle, key_info->key,
 				    &def_key_idx, &key_info->numKeys);
+	} else if ((key_info->encType == eSIR_ED_WEP40) ||
+		(key_info->encType == eSIR_ED_WEP104)) {
+		struct wma_txrx_node *intf =
+			&wma_handle->interfaces[key_info->smesessionId];
+		key_params.def_key_idx = intf->wep_default_key_idx;
 	}
 
 	for (i = 0; i < key_info->numKeys; i++) {