hostapd: improve ucode bss notifications
authorFelix Fietkau <nbd@nbd.name>
Wed, 17 Jul 2024 16:33:43 +0000 (18:33 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 21 Sep 2024 16:32:26 +0000 (18:32 +0200)
Reduce code duplication, add extra callback for bss create

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/network/services/hostapd/files/hostapd.uc
package/network/services/hostapd/patches/601-ucode_support.patch
package/network/services/hostapd/patches/780-Implement-APuP-Access-Point-Micro-Peering.patch
package/network/services/hostapd/patches/790-APuP-add-ubus-notification-when-a-peer-comes-up.patch
package/network/services/hostapd/patches/800-APuP-add-ucode-hook-for-when-a-peer-comes-up.patch
package/network/services/hostapd/src/src/ap/ucode.c
package/network/services/hostapd/src/src/ap/ucode.h

index dfddf8185ba8ef5ff72f43210aa4f1cfd32e7949..e30e3e9b02fae4a711d6bd4e64dad8b0fa0bbc90 100644 (file)
@@ -889,13 +889,13 @@ return {
                hostapd.udebug_set(null);
                hostapd.ubus.disconnect();
        },
-       bss_add: function(name, obj) {
+       bss_add: function(phy, name, obj) {
                bss_event("add", name);
        },
-       bss_reload: function(name, obj, reconf) {
+       bss_reload: function(phy, name, obj, reconf) {
                bss_event("reload", name, { reconf: reconf != 0 });
        },
-       bss_remove: function(name, obj) {
+       bss_remove: function(phy, name, obj) {
                bss_event("remove", name);
        }
 };
index 737966201491f147e343385cfced5a238b5e9b19..840711821933513bf4c068fb52b54ff8183531f0 100644 (file)
@@ -139,7 +139,16 @@ as adding/removing interfaces.
  {
        struct hostapd_bss_config *conf = hapd->conf;
        u8 ssid[SSID_MAX_LEN + 1];
-@@ -2954,7 +2958,7 @@ hostapd_alloc_bss_data(struct hostapd_if
+@@ -1510,6 +1514,8 @@ setup_mld:
+       }
+ #endif /* CONFIG_IEEE80211BE */
++      hostapd_ucode_create_bss(hapd);
++
+       if (conf->wmm_enabled < 0)
+               conf->wmm_enabled = hapd->iconf->ieee80211n |
+                       hapd->iconf->ieee80211ax;
+@@ -2954,7 +2960,7 @@ hostapd_alloc_bss_data(struct hostapd_if
  }
  
  
@@ -148,7 +157,7 @@ as adding/removing interfaces.
  {
        if (!hapd)
                return;
-@@ -4015,7 +4019,8 @@ int hostapd_remove_iface(struct hapd_int
+@@ -4015,7 +4021,8 @@ int hostapd_remove_iface(struct hapd_int
                hapd_iface = interfaces->iface[i];
                if (hapd_iface == NULL)
                        return -1;
index 22bd7ad26348886fe318e83c187449cfd21022b7..e72864efa1c673d4890aab9f808334df873f080b 100644 (file)
@@ -53,7 +53,7 @@ Hotfix-by: Sebastian Gottschall https://github.com/mirror/dd-wrt/commit/0c3001a6
  
 --- a/hostapd/config_file.c
 +++ b/hostapd/config_file.c
-@@ -5200,6 +5200,15 @@ static int hostapd_config_fill(struct ho
+@@ -5202,6 +5202,15 @@ static int hostapd_config_fill(struct ho
                bss->mld_indicate_disabled = atoi(pos);
  #endif /* CONFIG_TESTING_OPTIONS */
  #endif /* CONFIG_IEEE80211BE */
@@ -71,7 +71,7 @@ Hotfix-by: Sebastian Gottschall https://github.com/mirror/dd-wrt/commit/0c3001a6
                           "Line %d: unknown configuration item '%s'",
 --- a/src/ap/ap_config.h
 +++ b/src/ap/ap_config.h
-@@ -999,6 +999,35 @@ struct hostapd_bss_config {
+@@ -1000,6 +1000,35 @@ struct hostapd_bss_config {
        bool mld_indicate_disabled;
  #endif /* CONFIG_TESTING_OPTIONS */
  #endif /* CONFIG_IEEE80211BE */
index b0e2c57b1387c385c9fc5e21d7c8774c8bbf00f0..1efec5f806db01f08dfc627723663532a35178c6 100644 (file)
@@ -58,7 +58,7 @@ Signed-off-by: Gioacchino Mazzurco <gio@polymathes.cc>
 +#endif // def CONFIG_APUP
 --- a/src/ap/ubus.h
 +++ b/src/ap/ubus.h
-@@ -71,6 +71,11 @@ int hostapd_ubus_notify_bss_transition_q
+@@ -69,6 +69,11 @@ int hostapd_ubus_notify_bss_transition_q
  void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta,
                                    const char *auth_alg);
  
index d5c76994b4f6cceeaf71029a591d0e09d7924207..a4e2fe827b93d1c1320fc370fbb816cb7b729ced 100644 (file)
@@ -34,7 +34,7 @@ Signed-off-by: Gioacchino Mazzurco <gio@polymathes.cc>
  }
 --- a/src/ap/ucode.c
 +++ b/src/ap/ucode.c
-@@ -815,3 +815,20 @@ void hostapd_ucode_free_bss(struct hosta
+@@ -802,3 +802,20 @@ void hostapd_ucode_free_bss(struct hosta
        ucv_put(wpa_ucode_call(2));
        ucv_gc(vm);
  }
@@ -57,9 +57,9 @@ Signed-off-by: Gioacchino Mazzurco <gio@polymathes.cc>
 +#endif // def CONFIG_APUP
 --- a/src/ap/ucode.h
 +++ b/src/ap/ucode.h
-@@ -27,6 +27,10 @@ void hostapd_ucode_add_bss(struct hostap
+@@ -26,6 +26,10 @@ void hostapd_ucode_free_iface(struct hos
  void hostapd_ucode_free_bss(struct hostapd_data *hapd);
- void hostapd_ucode_reload_bss(struct hostapd_data *hapd);
+ void hostapd_ucode_bss_cb(struct hostapd_data *hapd, const char *type);
  
 +#ifdef CONFIG_APUP
 +void hostapd_ucode_apup_newpeer(struct hostapd_data *hapd, const char *ifname);
index c54f071ee0f5ea39a4684cdad0312f10ad839d80..751531d5a14ae9829d0b8c3b57dc08a39fa41c43 100644 (file)
@@ -770,31 +770,18 @@ void hostapd_ucode_free_iface(struct hostapd_iface *iface)
        wpa_ucode_registry_remove(iface_registry, iface->ucode.idx);
 }
 
-void hostapd_ucode_add_bss(struct hostapd_data *hapd)
+void hostapd_ucode_bss_cb(struct hostapd_data *hapd, const char *type)
 {
        uc_value_t *val;
 
-       if (wpa_ucode_call_prepare("bss_add"))
+       if (wpa_ucode_call_prepare(type))
                return;
 
        val = hostapd_ucode_bss_get_uval(hapd);
+       uc_value_push(ucv_get(ucv_string_new(hapd->iface->phy)));
        uc_value_push(ucv_get(ucv_string_new(hapd->conf->iface)));
        uc_value_push(ucv_get(val));
-       ucv_put(wpa_ucode_call(2));
-       ucv_gc(vm);
-}
-
-void hostapd_ucode_reload_bss(struct hostapd_data *hapd)
-{
-       uc_value_t *val;
-
-       if (wpa_ucode_call_prepare("bss_reload"))
-               return;
-
-       val = hostapd_ucode_bss_get_uval(hapd);
-       uc_value_push(ucv_get(ucv_string_new(hapd->conf->iface)));
-       uc_value_push(ucv_get(val));
-       ucv_put(wpa_ucode_call(2));
+       ucv_put(wpa_ucode_call(3));
        ucv_gc(vm);
 }
 
index d00b787169d10483397328ae7f08be220f88c6a2..53aa1f3e7fd166d88377b13295ca4c50c66a5238 100644 (file)
@@ -23,9 +23,8 @@ int hostapd_ucode_init(struct hapd_interfaces *ifaces);
 
 void hostapd_ucode_free(void);
 void hostapd_ucode_free_iface(struct hostapd_iface *iface);
-void hostapd_ucode_add_bss(struct hostapd_data *hapd);
 void hostapd_ucode_free_bss(struct hostapd_data *hapd);
-void hostapd_ucode_reload_bss(struct hostapd_data *hapd);
+void hostapd_ucode_bss_cb(struct hostapd_data *hapd, const char *type);
 
 #else
 
@@ -39,10 +38,7 @@ static inline void hostapd_ucode_free(void)
 static inline void hostapd_ucode_free_iface(struct hostapd_iface *iface)
 {
 }
-static inline void hostapd_ucode_reload_bss(struct hostapd_data *hapd)
-{
-}
-static inline void hostapd_ucode_add_bss(struct hostapd_data *hapd)
+static inline void hostapd_ucode_bss_cb(struct hostapd_data *hapd, const char *type)
 {
 }
 static inline void hostapd_ucode_free_bss(struct hostapd_data *hapd)
@@ -51,4 +47,19 @@ static inline void hostapd_ucode_free_bss(struct hostapd_data *hapd)
 
 #endif
 
+static inline void hostapd_ucode_create_bss(struct hostapd_data *hapd)
+{
+       hostapd_ucode_bss_cb(hapd, "bss_create");
+}
+
+static inline void hostapd_ucode_add_bss(struct hostapd_data *hapd)
+{
+       hostapd_ucode_bss_cb(hapd, "bss_add");
+}
+
+static inline void hostapd_ucode_reload_bss(struct hostapd_data *hapd)
+{
+       hostapd_ucode_bss_cb(hapd, "bss_reload");
+}
+
 #endif