wifi: mac80211: split ieee80211_drop_unencrypted_mgmt() return value

This has many different reasons, split the return value into
the individual reasons for better traceability. Also, since
symbolic tracing doesn't work for these, add a few comments
for the numbering.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2023-09-25 17:25:10 +02:00
parent dccc9aa7ee
commit 6c02fab724
2 changed files with 18 additions and 12 deletions

View File

@ -18,6 +18,7 @@ typedef unsigned int __bitwise ieee80211_rx_result;
/* this line for the trailing \ - add before this */ /* this line for the trailing \ - add before this */
#define MAC80211_DROP_REASONS_UNUSABLE(R) \ #define MAC80211_DROP_REASONS_UNUSABLE(R) \
/* 0x00 == ___RX_DROP_UNUSABLE */ \
R(RX_DROP_U_MIC_FAIL) \ R(RX_DROP_U_MIC_FAIL) \
R(RX_DROP_U_REPLAY) \ R(RX_DROP_U_REPLAY) \
R(RX_DROP_U_BAD_MMIE) \ R(RX_DROP_U_BAD_MMIE) \
@ -33,8 +34,15 @@ typedef unsigned int __bitwise ieee80211_rx_result;
R(RX_DROP_U_BAD_AMSDU) \ R(RX_DROP_U_BAD_AMSDU) \
R(RX_DROP_U_BAD_AMSDU_CIPHER) \ R(RX_DROP_U_BAD_AMSDU_CIPHER) \
R(RX_DROP_U_INVALID_8023) \ R(RX_DROP_U_INVALID_8023) \
/* 0x10 */ \
R(RX_DROP_U_RUNT_ACTION) \ R(RX_DROP_U_RUNT_ACTION) \
R(RX_DROP_U_UNPROT_ACTION) \ R(RX_DROP_U_UNPROT_ACTION) \
R(RX_DROP_U_UNPROT_DUAL) \
R(RX_DROP_U_UNPROT_UCAST_MGMT) \
R(RX_DROP_U_UNPROT_MCAST_MGMT) \
R(RX_DROP_U_UNPROT_BEACON) \
R(RX_DROP_U_UNPROT_UNICAST_PUB_ACTION) \
R(RX_DROP_U_UNPROT_ROBUST_ACTION) \
R(RX_DROP_U_ACTION_UNKNOWN_SRC) \ R(RX_DROP_U_ACTION_UNKNOWN_SRC) \
R(RX_DROP_U_REJECTED_ACTION_RESPONSE) \ R(RX_DROP_U_REJECTED_ACTION_RESPONSE) \
R(RX_DROP_U_EXPECT_DEFRAG_PROT) \ R(RX_DROP_U_EXPECT_DEFRAG_PROT) \
@ -43,6 +51,7 @@ typedef unsigned int __bitwise ieee80211_rx_result;
R(RX_DROP_U_NO_ICV) \ R(RX_DROP_U_NO_ICV) \
R(RX_DROP_U_AP_RX_GROUPCAST) \ R(RX_DROP_U_AP_RX_GROUPCAST) \
R(RX_DROP_U_SHORT_MMIC) \ R(RX_DROP_U_SHORT_MMIC) \
/* 0x20 */ \
R(RX_DROP_U_MMIC_FAIL) \ R(RX_DROP_U_MMIC_FAIL) \
R(RX_DROP_U_SHORT_TKIP) \ R(RX_DROP_U_SHORT_TKIP) \
R(RX_DROP_U_TKIP_FAIL) \ R(RX_DROP_U_TKIP_FAIL) \

View File

@ -2416,12 +2416,12 @@ static int ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx)
* decrypted them already. * decrypted them already.
*/ */
if (status->flag & RX_FLAG_DECRYPTED) if (status->flag & RX_FLAG_DECRYPTED)
return 0; return RX_CONTINUE;
/* drop unicast protected dual (that wasn't protected) */ /* drop unicast protected dual (that wasn't protected) */
if (ieee80211_is_action(fc) && if (ieee80211_is_action(fc) &&
mgmt->u.action.category == WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION) mgmt->u.action.category == WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION)
return -EACCES; return RX_DROP_U_UNPROT_DUAL;
if (rx->sta && test_sta_flag(rx->sta, WLAN_STA_MFP)) { if (rx->sta && test_sta_flag(rx->sta, WLAN_STA_MFP)) {
if (unlikely(!ieee80211_has_protected(fc) && if (unlikely(!ieee80211_has_protected(fc) &&
@ -2433,13 +2433,13 @@ static int ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx)
* during 4-way-HS (key is installed after HS). * during 4-way-HS (key is installed after HS).
*/ */
if (!rx->key) if (!rx->key)
return 0; return RX_CONTINUE;
cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev,
rx->skb->data, rx->skb->data,
rx->skb->len); rx->skb->len);
} }
return -EACCES; return RX_DROP_U_UNPROT_UCAST_MGMT;
} }
/* BIP does not use Protected field, so need to check MMIE */ /* BIP does not use Protected field, so need to check MMIE */
if (unlikely(ieee80211_is_multicast_robust_mgmt_frame(rx->skb) && if (unlikely(ieee80211_is_multicast_robust_mgmt_frame(rx->skb) &&
@ -2449,14 +2449,14 @@ static int ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx)
cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev,
rx->skb->data, rx->skb->data,
rx->skb->len); rx->skb->len);
return -EACCES; return RX_DROP_U_UNPROT_MCAST_MGMT;
} }
if (unlikely(ieee80211_is_beacon(fc) && rx->key && if (unlikely(ieee80211_is_beacon(fc) && rx->key &&
ieee80211_get_mmie_keyidx(rx->skb) < 0)) { ieee80211_get_mmie_keyidx(rx->skb) < 0)) {
cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev,
rx->skb->data, rx->skb->data,
rx->skb->len); rx->skb->len);
return -EACCES; return RX_DROP_U_UNPROT_BEACON;
} }
/* /*
* When using MFP, Action frames are not allowed prior to * When using MFP, Action frames are not allowed prior to
@ -2464,13 +2464,13 @@ static int ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx)
*/ */
if (unlikely(ieee80211_is_action(fc) && !rx->key && if (unlikely(ieee80211_is_action(fc) && !rx->key &&
ieee80211_is_robust_mgmt_frame(rx->skb))) ieee80211_is_robust_mgmt_frame(rx->skb)))
return -EACCES; return RX_DROP_U_UNPROT_ACTION;
/* drop unicast public action frames when using MPF */ /* drop unicast public action frames when using MPF */
if (is_unicast_ether_addr(mgmt->da) && if (is_unicast_ether_addr(mgmt->da) &&
ieee80211_is_public_action((void *)rx->skb->data, ieee80211_is_public_action((void *)rx->skb->data,
rx->skb->len)) rx->skb->len))
return -EACCES; return RX_DROP_U_UNPROT_UNICAST_PUB_ACTION;
} }
return 0; return 0;
@ -3400,10 +3400,7 @@ ieee80211_rx_h_mgmt_check(struct ieee80211_rx_data *rx)
rx->flags |= IEEE80211_RX_BEACON_REPORTED; rx->flags |= IEEE80211_RX_BEACON_REPORTED;
} }
if (ieee80211_drop_unencrypted_mgmt(rx)) return ieee80211_drop_unencrypted_mgmt(rx);
return RX_DROP_U_UNPROT_ACTION;
return RX_CONTINUE;
} }
static bool static bool