Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46e6de15 authored by Johannes Berg's avatar Johannes Berg
Browse files

mac80211: restructure key selection



The "no key" case in key selection that decides
whether to drop the frame or not is impossible
to understand, restructure the code.

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
[cavallar@lri.fr: removed blank line and restructured action frame clause]
Signed-off-by: default avatarNicolas Cavallari <cavallar@lri.fr>
parent 8c358bcd
Loading
Loading
Loading
Loading
+13 −9
Original line number Original line Diff line number Diff line
@@ -523,7 +523,7 @@ ieee80211_tx_h_check_control_port_protocol(struct ieee80211_tx_data *tx)
static ieee80211_tx_result debug_noinline
static ieee80211_tx_result debug_noinline
ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
{
{
	struct ieee80211_key *key = NULL;
	struct ieee80211_key *key;
	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;


@@ -542,16 +542,20 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
	else if (!is_multicast_ether_addr(hdr->addr1) &&
	else if (!is_multicast_ether_addr(hdr->addr1) &&
		 (key = rcu_dereference(tx->sdata->default_unicast_key)))
		 (key = rcu_dereference(tx->sdata->default_unicast_key)))
		tx->key = key;
		tx->key = key;
	else if (tx->sdata->drop_unencrypted &&
	else if (info->flags & IEEE80211_TX_CTL_INJECTED)
		 (tx->skb->protocol != tx->sdata->control_port_protocol) &&
		tx->key = NULL;
		 !(info->flags & IEEE80211_TX_CTL_INJECTED) &&
	else if (!tx->sdata->drop_unencrypted)
		 (!ieee80211_is_robust_mgmt_frame(hdr) ||
		tx->key = NULL;
		  (ieee80211_is_action(hdr->frame_control) &&
	else if (tx->skb->protocol == tx->sdata->control_port_protocol)
		   tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP)))) {
		tx->key = NULL;
	else if (ieee80211_is_robust_mgmt_frame(hdr) &&
		 !(ieee80211_is_action(hdr->frame_control) &&
		   tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP)))
		tx->key = NULL;
	else {
		I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
		I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
		return TX_DROP;
		return TX_DROP;
	} else
	}
		tx->key = NULL;


	if (tx->key) {
	if (tx->key) {
		bool skip_hw = false;
		bool skip_hw = false;