]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Add callback function for removing link STAs
authorAditya Kumar Singh <quic_adisi@quicinc.com>
Wed, 6 Mar 2024 06:41:03 +0000 (12:11 +0530)
committerJouni Malinen <j@w1.fi>
Wed, 27 Mar 2024 16:12:39 +0000 (18:12 +0200)
Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
src/ap/ap_drv_ops.h
src/drivers/driver.h
src/drivers/driver_nl80211.c

index e9da64d73c86ec0399cb06838b6233c48bb68a43..d7e79c840cb82c9bf6df9fa01e8b54d0092b9c53 100644 (file)
@@ -454,6 +454,7 @@ hostapd_drv_register_frame(struct hostapd_data *hapd, u16 type,
 #endif /* CONFIG_TESTING_OPTIONS */
 
 #ifdef CONFIG_IEEE80211BE
+
 static inline int hostapd_drv_link_add(struct hostapd_data *hapd,
                                       u8 link_id, const u8 *addr)
 {
@@ -463,6 +464,18 @@ static inline int hostapd_drv_link_add(struct hostapd_data *hapd,
        return hapd->driver->link_add(hapd->drv_priv, link_id, addr, hapd);
 
 }
+
+static inline int hostapd_drv_link_sta_remove(struct hostapd_data *hapd,
+                                             const u8 *addr)
+{
+       if (!hapd->conf->mld_ap || !hapd->driver || !hapd->drv_priv ||
+           !hapd->driver->link_sta_remove)
+               return -1;
+
+       return hapd->driver->link_sta_remove(hapd->drv_priv, hapd->mld_link_id,
+                                            addr);
+}
+
 #endif /* CONFIG_IEEE80211BE */
 
 #endif /* AP_DRV_OPS */
index 833dbc89513c1dad5f4e86c1591430e2641484c7..d67c949b65c2737aae31187d9489c46e7ffce3f2 100644 (file)
@@ -5178,6 +5178,15 @@ struct wpa_driver_ops {
         */
        bool (*is_drv_shared)(void *priv, void *bss_ctx);
 
+       /**
+        * link_sta_remove - Remove a link STA from an MLD STA
+        * @priv: Private driver interface data
+        * @link_id: The link ID which the link STA is using
+        * @addr: The MLD MAC address of the MLD STA
+        * Returns: 0 on success, negative value on failure
+        */
+       int (*link_sta_remove)(void *priv, u8 link_id, const u8 *addr);
+
 #ifdef CONFIG_TESTING_OPTIONS
        int (*register_frame)(void *priv, u16 type,
                              const u8 *match, size_t match_len,
index 7590b30abe13d579d56e0ffe30a3a86959db60f0..6666313dec7f1f58692890756cdfb1b077375a14 100644 (file)
@@ -13916,6 +13916,36 @@ static int nl80211_link_add(void *priv, u8 link_id, const u8 *addr,
 }
 
 
+#ifdef CONFIG_IEEE80211BE
+static int wpa_driver_nl80211_link_sta_remove(void *priv, u8 link_id,
+                                             const u8 *addr)
+{
+       struct i802_bss *bss = priv;
+       struct wpa_driver_nl80211_data *drv = bss->drv;
+       struct nl_msg *msg;
+       int ret;
+
+       if (!(bss->valid_links & BIT(link_id)))
+               return -ENOLINK;
+
+       if (!(msg = nl80211_bss_msg(bss, 0, NL80211_CMD_REMOVE_LINK_STA)) ||
+           nla_put(msg, NL80211_ATTR_MLD_ADDR, ETH_ALEN, addr) ||
+           nla_put_u8(msg, NL80211_ATTR_MLO_LINK_ID, link_id)) {
+               nlmsg_free(msg);
+               return -ENOBUFS;
+       }
+
+       ret = send_and_recv_cmd(drv, msg);
+       wpa_printf(MSG_DEBUG,
+                  "nl80211: link_sta_remove -> REMOVE_LINK_STA on link_id %u from MLD STA "
+                  MACSTR ", from %s --> %d (%s)",
+                  link_id, MAC2STR(addr), bss->ifname, ret, strerror(-ret));
+
+       return ret;
+}
+#endif /* CONFIG_IEEE80211BE */
+
+
 #ifdef CONFIG_TESTING_OPTIONS
 
 static int testing_nl80211_register_frame(void *priv, u16 type,
@@ -14113,6 +14143,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
 #ifdef CONFIG_IEEE80211BE
        .link_remove = driver_nl80211_link_remove,
        .is_drv_shared = nl80211_is_drv_shared,
+       .link_sta_remove = wpa_driver_nl80211_link_sta_remove,
 #endif /* CONFIG_IEEE80211BE */
 #ifdef CONFIG_TESTING_OPTIONS
        .register_frame = testing_nl80211_register_frame,