From: Felix Fietkau Date: Wed, 17 Jul 2024 16:33:43 +0000 (+0200) Subject: hostapd: improve ucode bss notifications X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=127078567bb6e239d925a52e848cdc33f47d3277;p=openwrt%2Fstaging%2Fansuel.git hostapd: improve ucode bss notifications Reduce code duplication, add extra callback for bss create Signed-off-by: Felix Fietkau --- diff --git a/package/network/services/hostapd/files/hostapd.uc b/package/network/services/hostapd/files/hostapd.uc index dfddf8185b..e30e3e9b02 100644 --- a/package/network/services/hostapd/files/hostapd.uc +++ b/package/network/services/hostapd/files/hostapd.uc @@ -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); } }; diff --git a/package/network/services/hostapd/patches/601-ucode_support.patch b/package/network/services/hostapd/patches/601-ucode_support.patch index 7379662014..8407118219 100644 --- a/package/network/services/hostapd/patches/601-ucode_support.patch +++ b/package/network/services/hostapd/patches/601-ucode_support.patch @@ -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; diff --git a/package/network/services/hostapd/patches/780-Implement-APuP-Access-Point-Micro-Peering.patch b/package/network/services/hostapd/patches/780-Implement-APuP-Access-Point-Micro-Peering.patch index 22bd7ad263..e72864efa1 100644 --- a/package/network/services/hostapd/patches/780-Implement-APuP-Access-Point-Micro-Peering.patch +++ b/package/network/services/hostapd/patches/780-Implement-APuP-Access-Point-Micro-Peering.patch @@ -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 */ diff --git a/package/network/services/hostapd/patches/790-APuP-add-ubus-notification-when-a-peer-comes-up.patch b/package/network/services/hostapd/patches/790-APuP-add-ubus-notification-when-a-peer-comes-up.patch index b0e2c57b13..1efec5f806 100644 --- a/package/network/services/hostapd/patches/790-APuP-add-ubus-notification-when-a-peer-comes-up.patch +++ b/package/network/services/hostapd/patches/790-APuP-add-ubus-notification-when-a-peer-comes-up.patch @@ -58,7 +58,7 @@ Signed-off-by: Gioacchino Mazzurco +#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); diff --git a/package/network/services/hostapd/patches/800-APuP-add-ucode-hook-for-when-a-peer-comes-up.patch b/package/network/services/hostapd/patches/800-APuP-add-ucode-hook-for-when-a-peer-comes-up.patch index d5c76994b4..a4e2fe827b 100644 --- a/package/network/services/hostapd/patches/800-APuP-add-ucode-hook-for-when-a-peer-comes-up.patch +++ b/package/network/services/hostapd/patches/800-APuP-add-ucode-hook-for-when-a-peer-comes-up.patch @@ -34,7 +34,7 @@ Signed-off-by: Gioacchino Mazzurco } --- 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 +#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); diff --git a/package/network/services/hostapd/src/src/ap/ucode.c b/package/network/services/hostapd/src/src/ap/ucode.c index c54f071ee0..751531d5a1 100644 --- a/package/network/services/hostapd/src/src/ap/ucode.c +++ b/package/network/services/hostapd/src/src/ap/ucode.c @@ -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); } diff --git a/package/network/services/hostapd/src/src/ap/ucode.h b/package/network/services/hostapd/src/src/ap/ucode.h index d00b787169..53aa1f3e7f 100644 --- a/package/network/services/hostapd/src/src/ap/ucode.h +++ b/package/network/services/hostapd/src/src/ap/ucode.h @@ -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