[openwrt/openwrt] hostapd: skip dynamic reconfiguration while not in enabled state

LEDE Commits lede-commits at lists.infradead.org
Sun Oct 5 02:31:46 PDT 2025


nbd pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/7b2c9f6799fd9b876e8e1440d3ff0d650c41a965

commit 7b2c9f6799fd9b876e8e1440d3ff0d650c41a965
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Fri Oct 3 15:32:25 2025 +0200

    hostapd: skip dynamic reconfiguration while not in enabled state
    
    Interface might be down or scanning. Better do a full restart in order to avoid
    messing up the runtime state.
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 package/network/services/hostapd/files/hostapd.uc  |  5 ++++
 .../network/services/hostapd/src/src/ap/ucode.c    | 30 ++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/package/network/services/hostapd/files/hostapd.uc b/package/network/services/hostapd/files/hostapd.uc
index 4bd53d6efe..17c34003e8 100644
--- a/package/network/services/hostapd/files/hostapd.uc
+++ b/package/network/services/hostapd/files/hostapd.uc
@@ -538,6 +538,11 @@ function iface_reload_config(name, phydev, config, old_config)
 		return false;
 	}
 
+	if (iface.state() != "ENABLED") {
+		hostapd.printf(`Interface ${iface_name} is not fully configured`);
+		return false;
+	}
+
 	let first_bss = get_config_bss(name, old_config, 0);
 	if (!first_bss) {
 		hostapd.printf(`Could not find bss of previous interface ${iface_name}`);
diff --git a/package/network/services/hostapd/src/src/ap/ucode.c b/package/network/services/hostapd/src/src/ap/ucode.c
index cca487c356..435174ca51 100644
--- a/package/network/services/hostapd/src/src/ap/ucode.c
+++ b/package/network/services/hostapd/src/src/ap/ucode.c
@@ -380,6 +380,35 @@ uc_hostapd_bss_delete(uc_vm_t *vm, size_t nargs)
 	return NULL;
 }
 
+static uc_value_t *
+uc_hostapd_iface_state(uc_vm_t *vm, size_t nargs)
+{
+#define hapd_state(name) [HAPD_IFACE_##name] = #name
+	static const char * const hapd_state_name[] = {
+		hapd_state(UNINITIALIZED),
+		hapd_state(DISABLED),
+		hapd_state(COUNTRY_UPDATE),
+		hapd_state(ACS),
+		hapd_state(HT_SCAN),
+		hapd_state(DFS),
+		hapd_state(NO_IR),
+		hapd_state(ENABLED),
+	};
+	struct hostapd_iface *iface = uc_fn_thisval("hostapd.iface");
+	const char *state = NULL;
+
+	if (!iface)
+		return NULL;
+
+	if (iface->state < ARRAY_SIZE(hapd_state_name))
+		state = hapd_state_name[iface->state];
+	if (!state)
+		state = "unknown";
+
+	return ucv_string_new(state);
+}
+
+
 static uc_value_t *
 uc_hostapd_iface_add_bss(uc_vm_t *vm, size_t nargs)
 {
@@ -930,6 +959,7 @@ int hostapd_ucode_init(struct hapd_interfaces *ifaces)
 		{ "delete", uc_hostapd_bss_delete },
 	};
 	static const uc_function_list_t iface_fns[] = {
+		{ "state", uc_hostapd_iface_state },
 		{ "set_bss_order", uc_hostapd_iface_set_bss_order },
 		{ "add_bss", uc_hostapd_iface_add_bss },
 		{ "stop", uc_hostapd_iface_stop },




More information about the lede-commits mailing list