[PATCH 2/7] hostapd: Add config_id parameter
Raphaël Mélotte
raphael.melotte at mind.be
Mon Aug 1 04:08:22 PDT 2022
Add a new configuration parameter: config_id.
If set, only do hostapd_clear_old() for the BSSes for which the
config_id changed.
This makes it possible to reconfigure specific BSSes on a radio,
without disconnecting clients connected to other, unchanged BSSes of
the same radio.
This patch adapted from a patch authored by John Crispin in the
OpenWrt repository:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/network/services/hostapd/patches/700-wifi-reload.patch;h=c5ba631a0fc02f70714cb081b42fcf6cb9694450;hb=60fb4c92b6b0d1582d31e02167b90b424185f3a2
Signed-off-by: Raphaël Mélotte <raphael.melotte at mind.be>
---
hostapd/config_file.c | 3 +++
src/ap/ap_config.c | 1 +
src/ap/ap_config.h | 1 +
src/ap/hostapd.c | 8 ++++++--
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index b04c65570..d0c6d8c77 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -2418,6 +2418,9 @@ static int hostapd_config_fill(struct hostapd_config *conf,
bss->ap_max_inactivity = atoi(pos);
} else if (os_strcmp(buf, "skip_inactivity_poll") == 0) {
bss->skip_inactivity_poll = atoi(pos);
+ } else if (os_strcmp(buf, "config_id") == 0) {
+ os_free(bss->config_id);
+ bss->config_id = os_strdup(pos);
} else if (os_strcmp(buf, "country_code") == 0) {
if (pos[0] < 'A' || pos[0] > 'Z' ||
pos[1] < 'A' || pos[1] > 'Z') {
diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
index d2d8b95f9..be2e47122 100644
--- a/src/ap/ap_config.c
+++ b/src/ap/ap_config.c
@@ -796,6 +796,7 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
os_free(conf->radius_req_attr_sqlite);
os_free(conf->rsn_preauth_interfaces);
os_free(conf->ctrl_interface);
+ os_free(conf->config_id);
os_free(conf->ca_cert);
os_free(conf->server_cert);
os_free(conf->server_cert2);
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index c5701cc00..a196d858f 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -916,6 +916,7 @@ struct hostapd_bss_config {
u8 ext_capa[EXT_CAPA_MAX_LEN];
u8 rnr;
+ char *config_id;
};
/**
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index b2c3cc30d..76b21895b 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -188,6 +188,7 @@ static void hostapd_clear_old_bss(struct hostapd_data *bss)
* items (e.g., open/close sockets, etc.) */
radius_client_flush(bss->radius, 0);
#endif /* CONFIG_NO_RADIUS */
+ wpa_printf(MSG_INFO, "bss %s changed", bss->conf->iface);
}
@@ -240,13 +241,13 @@ int hostapd_reload_config(struct hostapd_iface *iface)
if (newconf == NULL)
return -1;
- hostapd_clear_old(iface);
-
oldconf = hapd->iconf;
if (hostapd_iface_conf_changed(newconf, oldconf)) {
char *fname;
int res;
+ hostapd_clear_old(iface);
+
wpa_printf(MSG_DEBUG,
"Configuration changes include interface/BSS modification - force full disable+enable sequence");
fname = os_strdup(iface->config_fname);
@@ -276,6 +277,9 @@ int hostapd_reload_config(struct hostapd_iface *iface)
for (j = 0; j < iface->num_bss; j++) {
hapd = iface->bss[j];
+ if (!hapd->conf->config_id ||
+ strcmp(hapd->conf->config_id, newconf->bss[j]->config_id))
+ hostapd_clear_old_bss(hapd);
hapd->iconf = newconf;
hapd->iconf->channel = oldconf->channel;
hapd->iconf->acs = oldconf->acs;
--
2.37.1
More information about the Hostap
mailing list