]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: iwlwifi: mld: clean up station handling in key APIs
authorJohannes Berg <johannes.berg@intel.com>
Mon, 11 May 2026 17:36:23 +0000 (20:36 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Tue, 26 May 2026 12:17:09 +0000 (15:17 +0300)
The internal key APIs, when called with group keys where mac80211
doesn't pass the (AP) station pointer, are still sometimes called
with the AP station pointer on internal calls. This is confusing.
Clean it up and always call them with the AP STA when it exists,
even when coming in from mac80211, by looking it up immediately.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://patch.msgid.link/20260511203428.0efcbac3e96e.I5b78af51df283d452fc4f1366b04b4769f60f24e@changeid
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
drivers/net/wireless/intel/iwlwifi/mld/key.c
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c

index 04192c5f07ffce82ce48eccc208350f1b98d089c..2cb312ebd7a7dece9c3206585cebc9c47335abe3 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2024 Intel Corporation
+ * Copyright (C) 2024, 2026 Intel Corporation
  */
 #include "key.h"
 #include "iface.h"
@@ -12,7 +12,6 @@ static u32 iwl_mld_get_key_flags(struct iwl_mld *mld,
                                 struct ieee80211_sta *sta,
                                 struct ieee80211_key_conf *key)
 {
-       struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif);
        bool pairwise = key->flags & IEEE80211_KEY_FLAG_PAIRWISE;
        bool igtk = key->keyidx == 4 || key->keyidx == 5;
        u32 flags = 0;
@@ -38,9 +37,6 @@ static u32 iwl_mld_get_key_flags(struct iwl_mld *mld,
                break;
        }
 
-       if (!sta && vif->type == NL80211_IFTYPE_STATION)
-               sta = mld_vif->ap_sta;
-
        /* If we are installing an iGTK (in AP or STA mode), we need to tell
         * the firmware this key will en/decrypt MGMT frames.
         * Same goes if we are installing a pairwise key for an MFP station.
@@ -92,11 +88,7 @@ static u32 iwl_mld_get_key_sta_mask(struct iwl_mld *mld,
                return BIT(link->mcast_sta.sta_id);
        }
 
-       /* for client mode use the AP STA also for group keys */
-       if (!sta && vif->type == NL80211_IFTYPE_STATION)
-               sta = mld_vif->ap_sta;
-
-       /* STA should be non-NULL now */
+       /* STA should be non-NULL */
        if (WARN_ON(!sta))
                return 0;
 
index c02994e63b1418dcfba3b2ec5e1c6990f8a0d3ca..4b5f50ff2b0597bf0374506a3ea6d17c796c890c 100644 (file)
@@ -2282,9 +2282,20 @@ static int iwl_mld_mac80211_set_key(struct ieee80211_hw *hw,
                                    struct ieee80211_sta *sta,
                                    struct ieee80211_key_conf *key)
 {
+       struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif);
        struct iwl_mld *mld = IWL_MAC80211_GET_MLD(hw);
        int ret;
 
+       /*
+        * FW always needs the AP STA for client mode.
+        * Note that during removal this could already
+        * be NULL (mac80211 removes keys after STAs)
+        * but then we'll already have removed the key
+        * and set hw_key_idx = STA_KEY_IDX_INVALID.
+        */
+       if (!sta && vif->type == NL80211_IFTYPE_STATION)
+               sta = mld_vif->ap_sta;
+
        switch (cmd) {
        case SET_KEY:
                ret = iwl_mld_set_key_add(mld, vif, sta, key);