]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AP MLD: Provide Link ID when requesting current seqnum for a group key
authorJouni Malinen <quic_jouni@quicinc.com>
Thu, 15 Jun 2023 14:43:17 +0000 (17:43 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 15 Jun 2023 14:43:17 +0000 (17:43 +0300)
This is needed to match the key configuration design with a single
netdev and the nl80211 driver interface.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/ap/ap_drv_ops.c
src/ap/ap_drv_ops.h
src/ap/wpa_auth_glue.c
src/drivers/driver.h
src/drivers/driver_atheros.c
src/drivers/driver_bsd.c
src/drivers/driver_hostap.c
src/drivers/driver_nl80211.c
wpa_supplicant/driver_i.h

index 6864ed4020ae4ee05649821ce45318dbd0d34051..8f9cc5b3604eefdd20bb9b49d4077d2aaa51f52f 100644 (file)
@@ -553,12 +553,12 @@ int hostapd_set_ieee8021x(struct hostapd_data *hapd,
 
 
 int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
-                      const u8 *addr, int idx, u8 *seq)
+                      const u8 *addr, int idx, int link_id, u8 *seq)
 {
        if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
                return 0;
        return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
-                                       seq);
+                                       link_id, seq);
 }
 
 
index 25d9ee75e47588011a9a571f67d6230a3c70093e..331b0eaf4cdeccbe073092d4b6fe62a371a947d2 100644 (file)
@@ -62,7 +62,7 @@ int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
 int hostapd_set_ieee8021x(struct hostapd_data *hapd,
                          struct wpa_bss_params *params);
 int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
-                      const u8 *addr, int idx, u8 *seq);
+                      const u8 *addr, int idx, int link_id, u8 *seq);
 int hostapd_flush(struct hostapd_data *hapd);
 int hostapd_set_freq(struct hostapd_data *hapd, enum hostapd_hw_mode mode,
                     int freq, int channel, int edmg, u8 edmg_channel,
index eeeecaf4c55b543e281eaee22693004c40522c2d..c810619a4331554ffa91e7895616c4d8693bc242 100644 (file)
@@ -511,7 +511,14 @@ static int hostapd_wpa_auth_get_seqnum(void *ctx, const u8 *addr, int idx,
                                       u8 *seq)
 {
        struct hostapd_data *hapd = ctx;
-       return hostapd_get_seqnum(hapd->conf->iface, hapd, addr, idx, seq);
+       int link_id = -1;
+
+#ifdef CONFIG_IEEE80211BE
+       if (hapd->conf->mld_ap && idx)
+               link_id = hapd->mld_link_id;
+#endif /* CONFIG_IEEE80211BE */
+       return hostapd_get_seqnum(hapd->conf->iface, hapd, addr, idx, link_id,
+                                 seq);
 }
 
 
index 24daa25db280c883bc2ac5ebef4f1d485774044f..b6171dde35b9b0eb4792042267a317bcd4ee0d70 100644 (file)
@@ -3485,6 +3485,7 @@ struct wpa_driver_ops {
         * @priv: Private driver interface data
         * @addr: MAC address of the station or %NULL for group keys
         * @idx: Key index
+        * @link_id: Link ID for a group key, or -1 if not set
         * @seq: Buffer for returning the latest used TSC/packet number
         * Returns: 0 on success, -1 on failure
         *
@@ -3494,7 +3495,7 @@ struct wpa_driver_ops {
         * unicast keys (i.e., addr != %NULL).
         */
        int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
-                         int idx, u8 *seq);
+                         int idx, int link_id, u8 *seq);
 
        /**
         * flush - Flush all association stations (AP only)
index 22c8ff30c8907e0fedbc0dd5307204a4883be83e..08ff915acfb611a0bbefa210e26703aaa63d85ed 100644 (file)
@@ -586,7 +586,7 @@ atheros_set_key(void *priv, struct wpa_driver_set_key_params *params)
 
 static int
 atheros_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
-                  u8 *seq)
+                  int link_id, u8 *seq)
 {
        struct atheros_driver_data *drv = priv;
        struct ieee80211req_key wk;
index 13fcab5a155c794bc10113ad7e67925730afb983..c32d05e6520058f2ff0b0204c31d481e787bb689 100644 (file)
@@ -906,7 +906,7 @@ bsd_set_privacy(void *priv, int enabled)
 
 static int
 bsd_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
-              u8 *seq)
+              int link_id, u8 *seq)
 {
        struct ieee80211req_key wk;
 
index cf3b01e51b889c361fd7e7ca56deded48e71cae2..d3520aacc9883d46f2cf9ff656f3a2f86d62b6eb 100644 (file)
@@ -459,7 +459,7 @@ static int wpa_driver_hostap_set_key(void *priv,
 
 
 static int hostap_get_seqnum(const char *ifname, void *priv, const u8 *addr,
-                            int idx, u8 *seq)
+                            int idx, int link_id, u8 *seq)
 {
        struct hostap_driver_data *drv = priv;
        struct prism2_hostapd_param *param;
index 1df3145a69f12a629e9e3214bc0792d968247755..e4180daed27856e9f4e6d3ab837b8a8c06f51c7e 100644 (file)
@@ -7520,24 +7520,33 @@ static int get_key_handler(struct nl_msg *msg, void *arg)
 
 
 static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
-                          int idx, u8 *seq)
+                          int idx, int link_id, u8 *seq)
 {
        struct i802_bss *bss = priv;
        struct wpa_driver_nl80211_data *drv = bss->drv;
        struct nl_msg *msg;
+       int res;
 
        msg = nl80211_ifindex_msg(drv, if_nametoindex(iface), 0,
                                  NL80211_CMD_GET_KEY);
        if (!msg ||
            (addr && nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr)) ||
+           (link_id != NL80211_DRV_LINK_ID_NA &&
+            nla_put_u8(msg, NL80211_ATTR_MLO_LINK_ID, link_id)) ||
            nla_put_u8(msg, NL80211_ATTR_KEY_IDX, idx)) {
                nlmsg_free(msg);
                return -ENOBUFS;
        }
 
-       memset(seq, 0, 6);
+       os_memset(seq, 0, 6);
+       res = send_and_recv_msgs(drv, msg, get_key_handler, seq, NULL, NULL);
+       if (res) {
+               wpa_printf(MSG_DEBUG,
+                          "nl80211: Failed to get current TX sequence for a key (link_id=%d idx=%d): %d (%s)",
+                          link_id, idx, res, strerror(-res));
+       }
 
-       return send_and_recv_msgs(drv, msg, get_key_handler, seq, NULL, NULL);
+       return res;
 }
 
 
index 459a8e4ffc95327f061a7dc639bc3eca584f1319..48953c1d93bf1417da0549ebcc56909dcdb76275 100644 (file)
@@ -192,7 +192,7 @@ static inline int wpa_drv_get_seqnum(struct wpa_supplicant *wpa_s,
 {
        if (wpa_s->driver->get_seqnum)
                return wpa_s->driver->get_seqnum(wpa_s->ifname, wpa_s->drv_priv,
-                                                addr, idx, seq);
+                                                addr, idx, -1, seq);
        return -1;
 }