blob: c0e7e4d16e3229216f1e6176786616a1f53cca24 [file] [log] [blame]
developerf2e3f562022-12-26 19:41:22 +08001--- a/hostapd/config_file.c
2+++ b/hostapd/config_file.c
developer9a587882023-07-17 11:11:44 +08003@@ -2420,6 +2420,8 @@ static int hostapd_config_fill(struct ho
developerf2e3f562022-12-26 19:41:22 +08004 bss->isolate = atoi(pos);
5 } else if (os_strcmp(buf, "ap_max_inactivity") == 0) {
6 bss->ap_max_inactivity = atoi(pos);
7+ } else if (os_strcmp(buf, "config_id") == 0) {
8+ bss->config_id = os_strdup(pos);
9 } else if (os_strcmp(buf, "skip_inactivity_poll") == 0) {
10 bss->skip_inactivity_poll = atoi(pos);
developer5e0a8d72023-05-12 18:58:17 +080011 } else if (os_strcmp(buf, "config_id") == 0) {
developer9a587882023-07-17 11:11:44 +080012@@ -3130,6 +3132,8 @@ static int hostapd_config_fill(struct ho
developerf2e3f562022-12-26 19:41:22 +080013 }
14 } else if (os_strcmp(buf, "acs_exclude_dfs") == 0) {
15 conf->acs_exclude_dfs = atoi(pos);
16+ } else if (os_strcmp(buf, "radio_config_id") == 0) {
17+ conf->config_id = os_strdup(pos);
18 } else if (os_strcmp(buf, "op_class") == 0) {
19 conf->op_class = atoi(pos);
20 } else if (os_strcmp(buf, "channel") == 0) {
21--- a/src/ap/ap_config.c
22+++ b/src/ap/ap_config.c
developer9a587882023-07-17 11:11:44 +080023@@ -998,6 +998,7 @@ void hostapd_config_free(struct hostapd_
developerf2e3f562022-12-26 19:41:22 +080024
25 for (i = 0; i < conf->num_bss; i++)
26 hostapd_config_free_bss(conf->bss[i]);
27+ os_free(conf->config_id);
28 os_free(conf->bss);
29 os_free(conf->supported_rates);
30 os_free(conf->basic_rates);
31--- a/src/ap/ap_config.h
32+++ b/src/ap/ap_config.h
developer9a587882023-07-17 11:11:44 +080033@@ -998,6 +998,7 @@ struct eht_phy_capabilities_info {
developerf2e3f562022-12-26 19:41:22 +080034 struct hostapd_config {
35 struct hostapd_bss_config **bss, *last_bss;
36 size_t num_bss;
37+ char *config_id;
38
39 u16 beacon_int;
40 int rts_threshold;
41--- a/src/ap/hostapd.c
42+++ b/src/ap/hostapd.c
developerf0fd7052023-08-14 20:23:42 +080043@@ -127,7 +127,7 @@ void hostapd_reconfig_encryption(struct
44 }
45
46
47-static void hostapd_reload_bss(struct hostapd_data *hapd)
48+void hostapd_reload_bss(struct hostapd_data *hapd)
49 {
50 struct hostapd_ssid *ssid;
51
developer9a587882023-07-17 11:11:44 +080052@@ -255,6 +255,10 @@ static int hostapd_iface_conf_changed(st
developerf2e3f562022-12-26 19:41:22 +080053 {
54 size_t i;
55
56+ if (newconf->config_id != oldconf->config_id)
57+ if (strcmp(newconf->config_id, oldconf->config_id))
58+ return 1;
59+
60 if (newconf->num_bss != oldconf->num_bss)
61 return 1;
62
developer9a587882023-07-17 11:11:44 +080063@@ -268,7 +272,7 @@ static int hostapd_iface_conf_changed(st
developerf2e3f562022-12-26 19:41:22 +080064 }
65
66
67-int hostapd_reload_config(struct hostapd_iface *iface)
68+int hostapd_reload_config(struct hostapd_iface *iface, int reconf)
69 {
70 struct hapd_interfaces *interfaces = iface->interfaces;
71 struct hostapd_data *hapd = iface->bss[0];
developerf0fd7052023-08-14 20:23:42 +080072@@ -298,6 +302,9 @@ int hostapd_reload_config(struct hostapd
developerf2e3f562022-12-26 19:41:22 +080073 char *fname;
74 int res;
75
76+ if (reconf)
77+ return -1;
78+
developer5e0a8d72023-05-12 18:58:17 +080079 hostapd_clear_old(iface);
80
developerf2e3f562022-12-26 19:41:22 +080081 wpa_printf(MSG_DEBUG,
developerf0fd7052023-08-14 20:23:42 +080082@@ -324,6 +331,24 @@ int hostapd_reload_config(struct hostapd
developerf2e3f562022-12-26 19:41:22 +080083 wpa_printf(MSG_ERROR,
84 "Failed to enable interface on config reload");
85 return res;
86+ } else {
87+ for (j = 0; j < iface->num_bss; j++) {
88+ hapd = iface->bss[j];
89+ if (!hapd->config_id || strcmp(hapd->config_id, newconf->bss[j]->config_id)) {
90+ hostapd_flush_old_stations(iface->bss[j],
91+ WLAN_REASON_PREV_AUTH_NOT_VALID);
92+#ifdef CONFIG_WEP
93+ hostapd_broadcast_wep_clear(iface->bss[j]);
94+#endif
95+
96+#ifndef CONFIG_NO_RADIUS
97+ /* TODO: update dynamic data based on changed configuration
98+ * items (e.g., open/close sockets, etc.) */
99+ radius_client_flush(iface->bss[j]->radius, 0);
100+#endif /* CONFIG_NO_RADIUS */
101+ wpa_printf(MSG_INFO, "bss %zu changed", j);
102+ }
103+ }
104 }
105 iface->conf = newconf;
106
developerf0fd7052023-08-14 20:23:42 +0800107@@ -340,6 +365,12 @@ int hostapd_reload_config(struct hostapd
developerf2e3f562022-12-26 19:41:22 +0800108
109 for (j = 0; j < iface->num_bss; j++) {
110 hapd = iface->bss[j];
111+ if (hapd->config_id) {
112+ os_free(hapd->config_id);
113+ hapd->config_id = NULL;
114+ }
115+ if (newconf->bss[j]->config_id)
116+ hapd->config_id = strdup(newconf->bss[j]->config_id);
developer5e0a8d72023-05-12 18:58:17 +0800117 if (!hapd->conf->config_id || !newconf->bss[j]->config_id ||
118 os_strcmp(hapd->conf->config_id,
119 newconf->bss[j]->config_id) != 0)
developerf0fd7052023-08-14 20:23:42 +0800120@@ -1236,8 +1267,7 @@ static int hostapd_start_beacon(struct h
121 * initialized. Most of the modules that are initialized here will be
122 * deinitialized in hostapd_cleanup().
123 */
124-static int hostapd_setup_bss(struct hostapd_data *hapd, int first,
125- bool start_beacon)
126+int hostapd_setup_bss(struct hostapd_data *hapd, int first, bool start_beacon)
127 {
128 struct hostapd_bss_config *conf = hapd->conf;
129 u8 ssid[SSID_MAX_LEN + 1];
130@@ -2705,6 +2735,10 @@ hostapd_alloc_bss_data(struct hostapd_if
developerf2e3f562022-12-26 19:41:22 +0800131 hapd->iconf = conf;
132 hapd->conf = bss;
133 hapd->iface = hapd_iface;
134+ if (bss && bss->config_id)
135+ hapd->config_id = strdup(bss->config_id);
136+ else
137+ hapd->config_id = NULL;
138 if (conf)
139 hapd->driver = conf->driver;
140 hapd->ctrl_sock = -1;
developerf0fd7052023-08-14 20:23:42 +0800141@@ -2723,7 +2757,7 @@ hostapd_alloc_bss_data(struct hostapd_if
142 }
143
144
145-static void hostapd_bss_deinit(struct hostapd_data *hapd)
146+void hostapd_bss_deinit(struct hostapd_data *hapd)
147 {
148 if (!hapd)
149 return;
developerf2e3f562022-12-26 19:41:22 +0800150--- a/src/ap/hostapd.h
151+++ b/src/ap/hostapd.h
developerf0fd7052023-08-14 20:23:42 +0800152@@ -48,7 +48,7 @@ struct mesh_conf;
developerf2e3f562022-12-26 19:41:22 +0800153 struct hostapd_iface;
154
155 struct hapd_interfaces {
156- int (*reload_config)(struct hostapd_iface *iface);
157+ int (*reload_config)(struct hostapd_iface *iface, int reconf);
158 struct hostapd_config * (*config_read_cb)(const char *config_fname);
159 int (*ctrl_iface_init)(struct hostapd_data *hapd);
160 void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
developerf0fd7052023-08-14 20:23:42 +0800161@@ -192,6 +192,7 @@ struct hostapd_data {
developerf2e3f562022-12-26 19:41:22 +0800162 struct hostapd_bss_config *conf;
163 struct hostapd_ubus_bss ubus;
developerf0fd7052023-08-14 20:23:42 +0800164 struct hostapd_ucode_bss ucode;
developerf2e3f562022-12-26 19:41:22 +0800165+ char *config_id;
166 int interface_added; /* virtual interface added for this BSS */
167 unsigned int started:1;
168 unsigned int disabled:1;
developerf0fd7052023-08-14 20:23:42 +0800169@@ -696,7 +697,9 @@ struct hostapd_iface {
developerf2e3f562022-12-26 19:41:22 +0800170 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
171 int (*cb)(struct hostapd_iface *iface,
172 void *ctx), void *ctx);
173-int hostapd_reload_config(struct hostapd_iface *iface);
174+int hostapd_reload_config(struct hostapd_iface *iface, int reconf);
developerf0fd7052023-08-14 20:23:42 +0800175+void hostapd_reload_bss(struct hostapd_data *hapd);
176+void hostapd_bss_deinit(struct hostapd_data *hapd);
developerf2e3f562022-12-26 19:41:22 +0800177 void hostapd_reconfig_encryption(struct hostapd_data *hapd);
178 struct hostapd_data *
179 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
developerf0fd7052023-08-14 20:23:42 +0800180@@ -713,6 +716,7 @@ struct hostapd_iface * hostapd_init(stru
181 struct hostapd_iface *
182 hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
183 const char *config_fname, int debug);
184+int hostapd_setup_bss(struct hostapd_data *hapd, int first, bool start_beacon);
185 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
186 int reassoc);
187 void hostapd_interface_deinit_free(struct hostapd_iface *iface);
developerf2e3f562022-12-26 19:41:22 +0800188--- a/src/drivers/driver_nl80211.c
189+++ b/src/drivers/driver_nl80211.c
developer9a587882023-07-17 11:11:44 +0800190@@ -5322,6 +5322,9 @@ static int wpa_driver_nl80211_set_ap(voi
developerf2e3f562022-12-26 19:41:22 +0800191 if (ret) {
192 wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)",
193 ret, strerror(-ret));
developer5e0a8d72023-05-12 18:58:17 +0800194+ if (!bss->flink->beacon_set)
developerf2e3f562022-12-26 19:41:22 +0800195+ ret = 0;
developer5e0a8d72023-05-12 18:58:17 +0800196+ bss->flink->beacon_set = 0;
developerf2e3f562022-12-26 19:41:22 +0800197 } else {
developer9a587882023-07-17 11:11:44 +0800198 link->beacon_set = 1;
developerf2e3f562022-12-26 19:41:22 +0800199 nl80211_set_bss(bss, params->cts_protect, params->preamble,
200--- a/hostapd/ctrl_iface.c
201+++ b/hostapd/ctrl_iface.c
developer5e0a8d72023-05-12 18:58:17 +0800202@@ -187,7 +187,7 @@ static int hostapd_ctrl_iface_update(str
developerf2e3f562022-12-26 19:41:22 +0800203 iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
204 reload_opts = txt;
205
206- hostapd_reload_config(iface);
207+ hostapd_reload_config(iface, 0);
208
209 iface->interfaces->config_read_cb = config_read_cb;
210 }
211--- a/hostapd/main.c
212+++ b/hostapd/main.c
developer9a587882023-07-17 11:11:44 +0800213@@ -410,7 +410,7 @@ static void handle_term(int sig, void *s
developerf2e3f562022-12-26 19:41:22 +0800214
215 static int handle_reload_iface(struct hostapd_iface *iface, void *ctx)
216 {
217- if (hostapd_reload_config(iface) < 0) {
218+ if (hostapd_reload_config(iface, 0) < 0) {
219 wpa_printf(MSG_WARNING, "Failed to read new configuration "
220 "file - continuing with old.");
221 }
222--- a/src/ap/wps_hostapd.c
223+++ b/src/ap/wps_hostapd.c
224@@ -315,7 +315,7 @@ static void wps_reload_config(void *eloo
225
226 wpa_printf(MSG_DEBUG, "WPS: Reload configuration data");
227 if (iface->interfaces == NULL ||
228- iface->interfaces->reload_config(iface) < 0) {
229+ iface->interfaces->reload_config(iface, 1) < 0) {
230 wpa_printf(MSG_WARNING, "WPS: Failed to reload the updated "
231 "configuration");
232 }