Commit c56e00a3 authored by Johannes Berg's avatar Johannes Berg Committed by Luca Coelho

iwlwifi: mvm: delay GTK setting in FW in AP mode

In AP (and IBSS) mode, we can only set GTKs to firmware after we have
sent down the multicast station, but this we can only do after we've
enabled beaconing, etc.

However, during rfkill exit, hostapd will configure the keys before
starting the AP, and cfg80211/mac80211 accept it happily.

On earlier devices, this didn't bother us as GTK TX wasn't really
handled in firmware, we just put the key material into the TX cmd
and thus it only mattered when we actually transmitted a frame.

On newer devices, however, the firmware needs to track all of this
and that doesn't work if we add the key before the (multicast) sta
it belongs to.

To fix this, keep a list of keys to add during AP enable, and call
the function there.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent 5b7d6785
...@@ -207,6 +207,12 @@ static const struct cfg80211_pmsr_capabilities iwl_mvm_pmsr_capa = { ...@@ -207,6 +207,12 @@ static const struct cfg80211_pmsr_capabilities iwl_mvm_pmsr_capa = {
}, },
}; };
static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
enum set_key_cmd cmd,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
struct ieee80211_key_conf *key);
void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type)
{ {
if (!iwl_mvm_is_d0i3_supported(mvm)) if (!iwl_mvm_is_d0i3_supported(mvm))
...@@ -2637,7 +2643,7 @@ static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw, ...@@ -2637,7 +2643,7 @@ static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw,
{ {
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
int ret; int ret, i;
/* /*
* iwl_mvm_mac_ctxt_add() might read directly from the device * iwl_mvm_mac_ctxt_add() might read directly from the device
...@@ -2711,6 +2717,20 @@ static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw, ...@@ -2711,6 +2717,20 @@ static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw,
/* must be set before quota calculations */ /* must be set before quota calculations */
mvmvif->ap_ibss_active = true; mvmvif->ap_ibss_active = true;
/* send all the early keys to the device now */
for (i = 0; i < ARRAY_SIZE(mvmvif->ap_early_keys); i++) {
struct ieee80211_key_conf *key = mvmvif->ap_early_keys[i];
if (!key)
continue;
mvmvif->ap_early_keys[i] = NULL;
ret = iwl_mvm_mac_set_key(hw, SET_KEY, vif, NULL, key);
if (ret)
goto out_quota_failed;
}
if (vif->type == NL80211_IFTYPE_AP && !vif->p2p) { if (vif->type == NL80211_IFTYPE_AP && !vif->p2p) {
iwl_mvm_vif_set_low_latency(mvmvif, true, iwl_mvm_vif_set_low_latency(mvmvif, true,
LOW_LATENCY_VIF_TYPE); LOW_LATENCY_VIF_TYPE);
...@@ -3480,11 +3500,12 @@ static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, ...@@ -3480,11 +3500,12 @@ static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
struct ieee80211_sta *sta, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key) struct ieee80211_key_conf *key)
{ {
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
struct iwl_mvm_sta *mvmsta; struct iwl_mvm_sta *mvmsta;
struct iwl_mvm_key_pn *ptk_pn; struct iwl_mvm_key_pn *ptk_pn;
int keyidx = key->keyidx; int keyidx = key->keyidx;
int ret; int ret, i;
u8 key_offset; u8 key_offset;
if (iwlwifi_mod_params.swcrypto) { if (iwlwifi_mod_params.swcrypto) {
...@@ -3557,6 +3578,22 @@ static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, ...@@ -3557,6 +3578,22 @@ static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
key->hw_key_idx = STA_KEY_IDX_INVALID; key->hw_key_idx = STA_KEY_IDX_INVALID;
break; break;
} }
if (!mvmvif->ap_ibss_active) {
for (i = 0;
i < ARRAY_SIZE(mvmvif->ap_early_keys);
i++) {
if (!mvmvif->ap_early_keys[i]) {
mvmvif->ap_early_keys[i] = key;
break;
}
}
if (i >= ARRAY_SIZE(mvmvif->ap_early_keys))
ret = -ENOSPC;
break;
}
} }
/* During FW restart, in order to restore the state as it was, /* During FW restart, in order to restore the state as it was,
...@@ -3625,6 +3662,18 @@ static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, ...@@ -3625,6 +3662,18 @@ static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
break; break;
case DISABLE_KEY: case DISABLE_KEY:
ret = -ENOENT;
for (i = 0; i < ARRAY_SIZE(mvmvif->ap_early_keys); i++) {
if (mvmvif->ap_early_keys[i] == key) {
mvmvif->ap_early_keys[i] = NULL;
ret = 0;
}
}
/* found in pending list - don't do anything else */
if (ret == 0)
break;
if (key->hw_key_idx == STA_KEY_IDX_INVALID) { if (key->hw_key_idx == STA_KEY_IDX_INVALID) {
ret = 0; ret = 0;
break; break;
......
...@@ -501,6 +501,9 @@ struct iwl_mvm_vif { ...@@ -501,6 +501,9 @@ struct iwl_mvm_vif {
netdev_features_t features; netdev_features_t features;
struct iwl_probe_resp_data __rcu *probe_resp_data; struct iwl_probe_resp_data __rcu *probe_resp_data;
/* we can only have 2 GTK + 2 IGTK active at a time */
struct ieee80211_key_conf *ap_early_keys[4];
}; };
static inline struct iwl_mvm_vif * static inline struct iwl_mvm_vif *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment