|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
2 | 2 | /* |
3 | | - * Copyright (C) 2022 - 2023 Intel Corporation |
| 3 | + * Copyright (C) 2022 - 2024 Intel Corporation |
4 | 4 | */ |
5 | 5 | #include <linux/kernel.h> |
6 | 6 | #include <net/mac80211.h> |
@@ -62,11 +62,13 @@ u32 iwl_mvm_get_sec_flags(struct iwl_mvm *mvm, |
62 | 62 | struct ieee80211_key_conf *keyconf) |
63 | 63 | { |
64 | 64 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 65 | + bool pairwise = keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE; |
| 66 | + bool igtk = keyconf->keyidx == 4 || keyconf->keyidx == 5; |
65 | 67 | u32 flags = 0; |
66 | 68 |
|
67 | 69 | lockdep_assert_held(&mvm->mutex); |
68 | 70 |
|
69 | | - if (!(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE)) |
| 71 | + if (!pairwise) |
70 | 72 | flags |= IWL_SEC_KEY_FLAG_MCAST_KEY; |
71 | 73 |
|
72 | 74 | switch (keyconf->cipher) { |
@@ -96,12 +98,14 @@ u32 iwl_mvm_get_sec_flags(struct iwl_mvm *mvm, |
96 | 98 | if (!sta && vif->type == NL80211_IFTYPE_STATION) |
97 | 99 | sta = mvmvif->ap_sta; |
98 | 100 |
|
99 | | - /* Set the MFP flag also for an AP interface where the key is an IGTK |
100 | | - * key as in such a case the station would always be NULL |
| 101 | + /* |
| 102 | + * If we are installing an iGTK (in AP or STA mode), we need to tell |
| 103 | + * the firmware this key will en/decrypt MGMT frames. |
| 104 | + * Same goes if we are installing a pairwise key for an MFP station. |
| 105 | + * In case we're installing a groupwise key (which is not an iGTK), |
| 106 | + * then, we will not use this key for MGMT frames. |
101 | 107 | */ |
102 | | - if ((!IS_ERR_OR_NULL(sta) && sta->mfp) || |
103 | | - (vif->type == NL80211_IFTYPE_AP && |
104 | | - (keyconf->keyidx == 4 || keyconf->keyidx == 5))) |
| 108 | + if ((!IS_ERR_OR_NULL(sta) && sta->mfp && pairwise) || igtk) |
105 | 109 | flags |= IWL_SEC_KEY_FLAG_MFP; |
106 | 110 |
|
107 | 111 | return flags; |
|
0 commit comments