meta-netmodule-wlan/recipes-connectivity/hostapd/files/700-wifi-reload.patch

206 lines
7.0 KiB
Diff

diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index e0589d540..ec7955179 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -2418,6 +2418,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
bss->isolate = atoi(pos);
} else if (os_strcmp(buf, "ap_max_inactivity") == 0) {
bss->ap_max_inactivity = atoi(pos);
+ } else if (os_strcmp(buf, "config_id") == 0) {
+ bss->config_id = os_strdup(pos);
} else if (os_strcmp(buf, "skip_inactivity_poll") == 0) {
bss->skip_inactivity_poll = atoi(pos);
} else if (os_strcmp(buf, "config_id") == 0) {
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 0b4de6999..92b5f90db 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -187,7 +187,7 @@ static int hostapd_ctrl_iface_update(struct hostapd_data *hapd, char *txt)
iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
reload_opts = txt;
- hostapd_reload_config(iface);
+ hostapd_reload_config(iface, 0);
iface->interfaces->config_read_cb = config_read_cb;
}
diff --git a/hostapd/main.c b/hostapd/main.c
index 1b1575e04..b4ef3485f 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -410,7 +410,7 @@ static void handle_term(int sig, void *signal_ctx)
static int handle_reload_iface(struct hostapd_iface *iface, void *ctx)
{
- if (hostapd_reload_config(iface) < 0) {
+ if (hostapd_reload_config(iface,0 ) < 0) {
wpa_printf(MSG_WARNING, "Failed to read new configuration "
"file - continuing with old.");
}
diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
index 298216a47..41c70708d 100644
--- a/src/ap/ap_config.c
+++ b/src/ap/ap_config.c
@@ -998,6 +998,7 @@ void hostapd_config_free(struct hostapd_config *conf)
for (i = 0; i < conf->num_bss; i++)
hostapd_config_free_bss(conf->bss[i]);
+ os_free(conf->config_id);
os_free(conf->bss);
os_free(conf->supported_rates);
os_free(conf->basic_rates);
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 76f20c3c1..5628da1d0 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -998,6 +998,7 @@ struct eht_phy_capabilities_info {
struct hostapd_config {
struct hostapd_bss_config **bss, *last_bss;
size_t num_bss;
+ char *config_id;
u16 beacon_int;
int rts_threshold;
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 7a1d24459..986c64a1e 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -255,6 +255,10 @@ static int hostapd_iface_conf_changed(struct hostapd_config *newconf,
{
size_t i;
+ if (newconf->config_id != oldconf->config_id)
+ if (strcmp(newconf->config_id, oldconf->config_id))
+ return 1;
+
if (newconf->num_bss != oldconf->num_bss)
return 1;
@@ -268,7 +272,7 @@ static int hostapd_iface_conf_changed(struct hostapd_config *newconf,
}
-int hostapd_reload_config(struct hostapd_iface *iface)
+int hostapd_reload_config(struct hostapd_iface *iface, int reconf)
{
struct hapd_interfaces *interfaces = iface->interfaces;
struct hostapd_data *hapd = iface->bss[0];
@@ -296,6 +300,9 @@ int hostapd_reload_config(struct hostapd_iface *iface)
char *fname;
int res;
+ if (reconf)
+ return -1;
+
hostapd_clear_old(iface);
wpa_printf(MSG_DEBUG,
@@ -322,7 +329,26 @@ int hostapd_reload_config(struct hostapd_iface *iface)
wpa_printf(MSG_ERROR,
"Failed to enable interface on config reload");
return res;
+ } else {
+ for (j = 0; j < iface->num_bss; j++) {
+ hapd = iface->bss[j];
+ if (!hapd->config_id || strcmp(hapd->config_id, newconf->bss[j]->config_id)) {
+ hostapd_flush_old_stations(iface->bss[j],
+ + WLAN_REASON_PREV_AUTH_NOT_VALID);
+#ifdef CONFIG_WEP
+ hostapd_broadcast_wep_clear(iface->bss[j]);
+#endif
+
+#ifndef CONFIG_NO_RADIUS
+ /* TODO: update dynamic data based on changed configuration
+ * items (e.g., open/close sockets, etc.) */
+ radius_client_flush(iface->bss[j]->radius, 0);
+#endif /* CONFIG_NO_RADIUS */
+ wpa_printf(MSG_INFO, "bss %zu changed", j);
+ }
+ }
}
+
iface->conf = newconf;
for (i = 0; i < iface->num_hw_features; i++) {
@@ -338,6 +364,12 @@ int hostapd_reload_config(struct hostapd_iface *iface)
for (j = 0; j < iface->num_bss; j++) {
hapd = iface->bss[j];
+ if (hapd->config_id) {
+ os_free(hapd->config_id);
+ hapd->config_id = NULL;
+ }
+ if (newconf->bss[j]->config_id)
+ hapd->config_id = strdup(newconf->bss[j]->config_id);
if (!hapd->conf->config_id || !newconf->bss[j]->config_id ||
os_strcmp(hapd->conf->config_id,
newconf->bss[j]->config_id) != 0)
@@ -2718,6 +2750,10 @@ hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
hapd->iconf = conf;
hapd->conf = bss;
hapd->iface = hapd_iface;
+ if (bss && bss->config_id)
+ hapd->config_id = strdup(bss->config_id);
+ else
+ hapd->config_id = NULL;
if (conf)
hapd->driver = conf->driver;
hapd->ctrl_sock = -1;
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index e9075e9f0..e122805ea 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -46,7 +46,7 @@ struct mesh_conf;
struct hostapd_iface;
struct hapd_interfaces {
- int (*reload_config)(struct hostapd_iface *iface);
+ int (*reload_config)(struct hostapd_iface *iface, int reconf);
struct hostapd_config * (*config_read_cb)(const char *config_fname);
int (*ctrl_iface_init)(struct hostapd_data *hapd);
void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
@@ -184,6 +184,7 @@ struct hostapd_data {
struct hostapd_iface *iface;
struct hostapd_config *iconf;
struct hostapd_bss_config *conf;
+ char *config_id;
int interface_added; /* virtual interface added for this BSS */
unsigned int started:1;
unsigned int disabled:1;
@@ -687,7 +688,7 @@ struct hostapd_iface {
int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
int (*cb)(struct hostapd_iface *iface,
void *ctx), void *ctx);
-int hostapd_reload_config(struct hostapd_iface *iface);
+int hostapd_reload_config(struct hostapd_iface *iface, int reconf);
void hostapd_reconfig_encryption(struct hostapd_data *hapd);
struct hostapd_data *
hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c
index 0c351af5f..e4f303bdc 100644
--- a/src/ap/wps_hostapd.c
+++ b/src/ap/wps_hostapd.c
@@ -315,7 +315,7 @@ static void wps_reload_config(void *eloop_data, void *user_ctx)
wpa_printf(MSG_DEBUG, "WPS: Reload configuration data");
if (iface->interfaces == NULL ||
- iface->interfaces->reload_config(iface) < 0) {
+ iface->interfaces->reload_config(iface, 1) < 0) {
wpa_printf(MSG_WARNING, "WPS: Failed to reload the updated "
"configuration");
}
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 99870a60d..70d98e7d4 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -5322,6 +5322,9 @@ static int wpa_driver_nl80211_set_ap(void *priv,
if (ret) {
wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)",
ret, strerror(-ret));
+ if (!bss->flink->beacon_set)
+ ret = 0;
+ bss->flink->beacon_set = 0;
} else {
link->beacon_set = 1;
nl80211_set_bss(bss, params->cts_protect, params->preamble,