blob: e6d7c2f6738b3f45d370f86fe0015d6275017735 [file] [log] [blame]
developer4e0da232022-05-09 13:05:53 +08001--- a/hostapd/config_file.c
2+++ b/hostapd/config_file.c
3@@ -2458,6 +2458,8 @@ static int hostapd_config_fill(struct ho
4 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);
11 } else if (os_strcmp(buf, "country_code") == 0) {
12@@ -3158,6 +3160,8 @@ static int hostapd_config_fill(struct ho
13 }
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
23@@ -792,6 +792,7 @@ void hostapd_config_free_bss(struct host
24 os_free(conf->radius_req_attr_sqlite);
25 os_free(conf->rsn_preauth_interfaces);
26 os_free(conf->ctrl_interface);
27+ os_free(conf->config_id);
28 os_free(conf->ca_cert);
29 os_free(conf->server_cert);
30 os_free(conf->server_cert2);
31@@ -988,6 +989,7 @@ void hostapd_config_free(struct hostapd_
32
33 for (i = 0; i < conf->num_bss; i++)
34 hostapd_config_free_bss(conf->bss[i]);
35+ os_free(conf->config_id);
36 os_free(conf->bss);
37 os_free(conf->supported_rates);
38 os_free(conf->basic_rates);
39--- a/src/ap/ap_config.h
40+++ b/src/ap/ap_config.h
41@@ -279,6 +279,8 @@ struct hostapd_bss_config {
42 char vlan_bridge[IFNAMSIZ + 1];
43 char wds_bridge[IFNAMSIZ + 1];
44
45+ char *config_id;
46+
47 enum hostapd_logger_level logger_syslog_level, logger_stdout_level;
48
49 unsigned int logger_syslog; /* module bitfield */
50@@ -942,6 +944,7 @@ struct spatial_reuse {
51 struct hostapd_config {
52 struct hostapd_bss_config **bss, *last_bss;
53 size_t num_bss;
54+ char *config_id;
55
56 u16 beacon_int;
57 int rts_threshold;
58--- a/src/ap/hostapd.c
59+++ b/src/ap/hostapd.c
60@@ -219,6 +219,10 @@ static int hostapd_iface_conf_changed(st
61 {
62 size_t i;
63
64+ if (newconf->config_id != oldconf->config_id)
65+ if (strcmp(newconf->config_id, oldconf->config_id))
66+ return 1;
67+
68 if (newconf->num_bss != oldconf->num_bss)
69 return 1;
70
71@@ -232,7 +236,7 @@ static int hostapd_iface_conf_changed(st
72 }
73
74
75-int hostapd_reload_config(struct hostapd_iface *iface)
76+int hostapd_reload_config(struct hostapd_iface *iface, int reconf)
77 {
78 struct hapd_interfaces *interfaces = iface->interfaces;
79 struct hostapd_data *hapd = iface->bss[0];
80@@ -255,13 +259,16 @@ int hostapd_reload_config(struct hostapd
81 if (newconf == NULL)
82 return -1;
83
84- hostapd_clear_old(iface);
85-
86 oldconf = hapd->iconf;
87 if (hostapd_iface_conf_changed(newconf, oldconf)) {
88 char *fname;
89 int res;
90
91+ if (reconf)
92+ return -1;
93+
94+ hostapd_clear_old(iface);
95+
96 wpa_printf(MSG_DEBUG,
97 "Configuration changes include interface/BSS modification - force full disable+enable sequence");
98 fname = os_strdup(iface->config_fname);
99@@ -286,6 +293,24 @@ int hostapd_reload_config(struct hostapd
100 wpa_printf(MSG_ERROR,
101 "Failed to enable interface on config reload");
102 return res;
103+ } else {
104+ for (j = 0; j < iface->num_bss; j++) {
105+ hapd = iface->bss[j];
106+ if (!hapd->config_id || strcmp(hapd->config_id, newconf->bss[j]->config_id)) {
107+ hostapd_flush_old_stations(iface->bss[j],
108+ WLAN_REASON_PREV_AUTH_NOT_VALID);
109+#ifdef CONFIG_WEP
110+ hostapd_broadcast_wep_clear(iface->bss[j]);
111+#endif
112+
113+#ifndef CONFIG_NO_RADIUS
114+ /* TODO: update dynamic data based on changed configuration
115+ * items (e.g., open/close sockets, etc.) */
116+ radius_client_flush(iface->bss[j]->radius, 0);
117+#endif /* CONFIG_NO_RADIUS */
118+ wpa_printf(MSG_INFO, "bss %zu changed", j);
119+ }
120+ }
121 }
122 iface->conf = newconf;
123
124@@ -302,6 +327,12 @@ int hostapd_reload_config(struct hostapd
125
126 for (j = 0; j < iface->num_bss; j++) {
127 hapd = iface->bss[j];
128+ if (hapd->config_id) {
129+ os_free(hapd->config_id);
130+ hapd->config_id = NULL;
131+ }
132+ if (newconf->bss[j]->config_id)
133+ hapd->config_id = strdup(newconf->bss[j]->config_id);
134 hapd->iconf = newconf;
135 hapd->conf = newconf->bss[j];
136 hostapd_reload_bss(hapd);
137@@ -2397,6 +2428,10 @@ hostapd_alloc_bss_data(struct hostapd_if
138 hapd->iconf = conf;
139 hapd->conf = bss;
140 hapd->iface = hapd_iface;
141+ if (bss && bss->config_id)
142+ hapd->config_id = strdup(bss->config_id);
143+ else
144+ hapd->config_id = NULL;
145 if (conf)
146 hapd->driver = conf->driver;
147 hapd->ctrl_sock = -1;
148--- a/src/ap/hostapd.h
149+++ b/src/ap/hostapd.h
150@@ -46,7 +46,7 @@ struct mesh_conf;
151 struct hostapd_iface;
152
153 struct hapd_interfaces {
154- int (*reload_config)(struct hostapd_iface *iface);
155+ int (*reload_config)(struct hostapd_iface *iface, int reconf);
156 struct hostapd_config * (*config_read_cb)(const char *config_fname);
157 int (*ctrl_iface_init)(struct hostapd_data *hapd);
158 void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
159@@ -173,6 +173,7 @@ struct hostapd_data {
160 struct hostapd_config *iconf;
161 struct hostapd_bss_config *conf;
162 struct hostapd_ubus_bss ubus;
163+ char *config_id;
164 int interface_added; /* virtual interface added for this BSS */
165 unsigned int started:1;
166 unsigned int disabled:1;
167@@ -624,7 +625,7 @@ struct hostapd_iface {
168 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
169 int (*cb)(struct hostapd_iface *iface,
170 void *ctx), void *ctx);
171-int hostapd_reload_config(struct hostapd_iface *iface);
172+int hostapd_reload_config(struct hostapd_iface *iface, int reconf);
173 void hostapd_reconfig_encryption(struct hostapd_data *hapd);
174 struct hostapd_data *
175 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
176--- a/src/drivers/driver_nl80211.c
177+++ b/src/drivers/driver_nl80211.c
178@@ -4833,6 +4833,9 @@ static int wpa_driver_nl80211_set_ap(voi
179 if (ret) {
180 wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)",
181 ret, strerror(-ret));
182+ if (!bss->beacon_set)
183+ ret = 0;
184+ bss->beacon_set = 0;
185 } else {
186 bss->beacon_set = 1;
187 nl80211_set_bss(bss, params->cts_protect, params->preamble,
188--- a/hostapd/ctrl_iface.c
189+++ b/hostapd/ctrl_iface.c
190@@ -186,7 +186,7 @@ static int hostapd_ctrl_iface_update(str
191 iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
192 reload_opts = txt;
193
194- hostapd_reload_config(iface);
195+ hostapd_reload_config(iface, 0);
196
197 iface->interfaces->config_read_cb = config_read_cb;
198 }
199--- a/hostapd/main.c
200+++ b/hostapd/main.c
201@@ -317,7 +317,7 @@ static void handle_term(int sig, void *s
202
203 static int handle_reload_iface(struct hostapd_iface *iface, void *ctx)
204 {
205- if (hostapd_reload_config(iface) < 0) {
206+ if (hostapd_reload_config(iface, 0) < 0) {
207 wpa_printf(MSG_WARNING, "Failed to read new configuration "
208 "file - continuing with old.");
209 }
210--- a/src/ap/wps_hostapd.c
211+++ b/src/ap/wps_hostapd.c
212@@ -315,7 +315,7 @@ static void wps_reload_config(void *eloo
213
214 wpa_printf(MSG_DEBUG, "WPS: Reload configuration data");
215 if (iface->interfaces == NULL ||
216- iface->interfaces->reload_config(iface) < 0) {
217+ iface->interfaces->reload_config(iface, 1) < 0) {
218 wpa_printf(MSG_WARNING, "WPS: Failed to reload the updated "
219 "configuration");
220 }