blob: 5ac7f711a5cdeed38aa3ea2cec38dd6377417da0 [file] [log] [blame]
developer29c4d2d2022-12-26 19:41:22 +08001--- a/hostapd/config_file.c
2+++ b/hostapd/config_file.c
developer505c9432023-05-12 18:58:17 +08003@@ -2418,6 +2418,8 @@ static int hostapd_config_fill(struct ho
developer29c4d2d2022-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);
developer505c9432023-05-12 18:58:17 +080011 } else if (os_strcmp(buf, "config_id") == 0) {
12@@ -3128,6 +3130,8 @@ static int hostapd_config_fill(struct ho
developer29c4d2d2022-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
developer505c9432023-05-12 18:58:17 +080023@@ -997,6 +997,7 @@ void hostapd_config_free(struct hostapd_
developer29c4d2d2022-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
developer505c9432023-05-12 18:58:17 +080033@@ -987,6 +987,7 @@ struct eht_phy_capabilities_info {
developer29c4d2d2022-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
developer505c9432023-05-12 18:58:17 +080043@@ -254,6 +254,10 @@ static int hostapd_iface_conf_changed(st
developer29c4d2d2022-12-26 19:41:22 +080044 {
45 size_t i;
46
47+ if (newconf->config_id != oldconf->config_id)
48+ if (strcmp(newconf->config_id, oldconf->config_id))
49+ return 1;
50+
51 if (newconf->num_bss != oldconf->num_bss)
52 return 1;
53
developer505c9432023-05-12 18:58:17 +080054@@ -267,7 +271,7 @@ static int hostapd_iface_conf_changed(st
developer29c4d2d2022-12-26 19:41:22 +080055 }
56
57
58-int hostapd_reload_config(struct hostapd_iface *iface)
59+int hostapd_reload_config(struct hostapd_iface *iface, int reconf)
60 {
61 struct hapd_interfaces *interfaces = iface->interfaces;
62 struct hostapd_data *hapd = iface->bss[0];
developer505c9432023-05-12 18:58:17 +080063@@ -295,6 +299,9 @@ int hostapd_reload_config(struct hostapd
developer29c4d2d2022-12-26 19:41:22 +080064 char *fname;
65 int res;
66
67+ if (reconf)
68+ return -1;
69+
developer505c9432023-05-12 18:58:17 +080070 hostapd_clear_old(iface);
71
developer29c4d2d2022-12-26 19:41:22 +080072 wpa_printf(MSG_DEBUG,
developer505c9432023-05-12 18:58:17 +080073@@ -321,6 +328,24 @@ int hostapd_reload_config(struct hostapd
developer29c4d2d2022-12-26 19:41:22 +080074 wpa_printf(MSG_ERROR,
75 "Failed to enable interface on config reload");
76 return res;
77+ } else {
78+ for (j = 0; j < iface->num_bss; j++) {
79+ hapd = iface->bss[j];
80+ if (!hapd->config_id || strcmp(hapd->config_id, newconf->bss[j]->config_id)) {
81+ hostapd_flush_old_stations(iface->bss[j],
82+ WLAN_REASON_PREV_AUTH_NOT_VALID);
83+#ifdef CONFIG_WEP
84+ hostapd_broadcast_wep_clear(iface->bss[j]);
85+#endif
86+
87+#ifndef CONFIG_NO_RADIUS
88+ /* TODO: update dynamic data based on changed configuration
89+ * items (e.g., open/close sockets, etc.) */
90+ radius_client_flush(iface->bss[j]->radius, 0);
91+#endif /* CONFIG_NO_RADIUS */
92+ wpa_printf(MSG_INFO, "bss %zu changed", j);
93+ }
94+ }
95 }
96 iface->conf = newconf;
97
developer505c9432023-05-12 18:58:17 +080098@@ -337,6 +362,12 @@ int hostapd_reload_config(struct hostapd
developer29c4d2d2022-12-26 19:41:22 +080099
100 for (j = 0; j < iface->num_bss; j++) {
101 hapd = iface->bss[j];
102+ if (hapd->config_id) {
103+ os_free(hapd->config_id);
104+ hapd->config_id = NULL;
105+ }
106+ if (newconf->bss[j]->config_id)
107+ hapd->config_id = strdup(newconf->bss[j]->config_id);
developer505c9432023-05-12 18:58:17 +0800108 if (!hapd->conf->config_id || !newconf->bss[j]->config_id ||
109 os_strcmp(hapd->conf->config_id,
110 newconf->bss[j]->config_id) != 0)
111@@ -2514,6 +2545,10 @@ hostapd_alloc_bss_data(struct hostapd_if
developer29c4d2d2022-12-26 19:41:22 +0800112 hapd->iconf = conf;
113 hapd->conf = bss;
114 hapd->iface = hapd_iface;
115+ if (bss && bss->config_id)
116+ hapd->config_id = strdup(bss->config_id);
117+ else
118+ hapd->config_id = NULL;
119 if (conf)
120 hapd->driver = conf->driver;
121 hapd->ctrl_sock = -1;
122--- a/src/ap/hostapd.h
123+++ b/src/ap/hostapd.h
124@@ -47,7 +47,7 @@ struct mesh_conf;
125 struct hostapd_iface;
126
127 struct hapd_interfaces {
128- int (*reload_config)(struct hostapd_iface *iface);
129+ int (*reload_config)(struct hostapd_iface *iface, int reconf);
130 struct hostapd_config * (*config_read_cb)(const char *config_fname);
131 int (*ctrl_iface_init)(struct hostapd_data *hapd);
132 void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
133@@ -185,6 +185,7 @@ struct hostapd_data {
134 struct hostapd_config *iconf;
135 struct hostapd_bss_config *conf;
136 struct hostapd_ubus_bss ubus;
137+ char *config_id;
138 int interface_added; /* virtual interface added for this BSS */
139 unsigned int started:1;
140 unsigned int disabled:1;
developer505c9432023-05-12 18:58:17 +0800141@@ -676,7 +677,7 @@ struct hostapd_iface {
developer29c4d2d2022-12-26 19:41:22 +0800142 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
143 int (*cb)(struct hostapd_iface *iface,
144 void *ctx), void *ctx);
145-int hostapd_reload_config(struct hostapd_iface *iface);
146+int hostapd_reload_config(struct hostapd_iface *iface, int reconf);
147 void hostapd_reconfig_encryption(struct hostapd_data *hapd);
148 struct hostapd_data *
149 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
150--- a/src/drivers/driver_nl80211.c
151+++ b/src/drivers/driver_nl80211.c
developer505c9432023-05-12 18:58:17 +0800152@@ -5054,6 +5054,9 @@ static int wpa_driver_nl80211_set_ap(voi
developer29c4d2d2022-12-26 19:41:22 +0800153 if (ret) {
154 wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)",
155 ret, strerror(-ret));
developer505c9432023-05-12 18:58:17 +0800156+ if (!bss->flink->beacon_set)
developer29c4d2d2022-12-26 19:41:22 +0800157+ ret = 0;
developer505c9432023-05-12 18:58:17 +0800158+ bss->flink->beacon_set = 0;
developer29c4d2d2022-12-26 19:41:22 +0800159 } else {
developer505c9432023-05-12 18:58:17 +0800160 bss->flink->beacon_set = 1;
developer29c4d2d2022-12-26 19:41:22 +0800161 nl80211_set_bss(bss, params->cts_protect, params->preamble,
162--- a/hostapd/ctrl_iface.c
163+++ b/hostapd/ctrl_iface.c
developer505c9432023-05-12 18:58:17 +0800164@@ -187,7 +187,7 @@ static int hostapd_ctrl_iface_update(str
developer29c4d2d2022-12-26 19:41:22 +0800165 iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
166 reload_opts = txt;
167
168- hostapd_reload_config(iface);
169+ hostapd_reload_config(iface, 0);
170
171 iface->interfaces->config_read_cb = config_read_cb;
172 }
173--- a/hostapd/main.c
174+++ b/hostapd/main.c
developer505c9432023-05-12 18:58:17 +0800175@@ -320,7 +320,7 @@ static void handle_term(int sig, void *s
developer29c4d2d2022-12-26 19:41:22 +0800176
177 static int handle_reload_iface(struct hostapd_iface *iface, void *ctx)
178 {
179- if (hostapd_reload_config(iface) < 0) {
180+ if (hostapd_reload_config(iface, 0) < 0) {
181 wpa_printf(MSG_WARNING, "Failed to read new configuration "
182 "file - continuing with old.");
183 }
184--- a/src/ap/wps_hostapd.c
185+++ b/src/ap/wps_hostapd.c
186@@ -315,7 +315,7 @@ static void wps_reload_config(void *eloo
187
188 wpa_printf(MSG_DEBUG, "WPS: Reload configuration data");
189 if (iface->interfaces == NULL ||
190- iface->interfaces->reload_config(iface) < 0) {
191+ iface->interfaces->reload_config(iface, 1) < 0) {
192 wpa_printf(MSG_WARNING, "WPS: Failed to reload the updated "
193 "configuration");
194 }