hostapd: remove config_id parameters from hostapd.conf
[openwrt/staging/thess.git] / package / network / services / hostapd / patches / 700-wifi-reload.patch
1 --- a/hostapd/config_file.c
2 +++ b/hostapd/config_file.c
3 @@ -2420,6 +2420,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, "config_id") == 0) {
12 @@ -3130,6 +3132,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 @@ -998,6 +998,7 @@ void hostapd_config_free(struct hostapd_
24
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
33 @@ -998,6 +998,7 @@ struct eht_phy_capabilities_info {
34 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
43 @@ -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
52 @@ -255,6 +255,10 @@ static int hostapd_iface_conf_changed(st
53 {
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
63 @@ -268,7 +272,7 @@ static int hostapd_iface_conf_changed(st
64 }
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];
72 @@ -298,6 +302,9 @@ int hostapd_reload_config(struct hostapd
73 char *fname;
74 int res;
75
76 + if (reconf)
77 + return -1;
78 +
79 hostapd_clear_old(iface);
80
81 wpa_printf(MSG_DEBUG,
82 @@ -324,6 +331,24 @@ int hostapd_reload_config(struct hostapd
83 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
107 @@ -340,6 +365,12 @@ int hostapd_reload_config(struct hostapd
108
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);
117 if (!hapd->conf->config_id || !newconf->bss[j]->config_id ||
118 os_strcmp(hapd->conf->config_id,
119 newconf->bss[j]->config_id) != 0)
120 @@ -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
131 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;
141 @@ -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;
150 --- a/src/ap/hostapd.h
151 +++ b/src/ap/hostapd.h
152 @@ -48,7 +48,7 @@ struct mesh_conf;
153 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);
161 @@ -192,6 +192,7 @@ struct hostapd_data {
162 struct hostapd_bss_config *conf;
163 struct hostapd_ubus_bss ubus;
164 struct hostapd_ucode_bss ucode;
165 + char *config_id;
166 int interface_added; /* virtual interface added for this BSS */
167 unsigned int started:1;
168 unsigned int disabled:1;
169 @@ -696,7 +697,9 @@ struct hostapd_iface {
170 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);
175 +void hostapd_reload_bss(struct hostapd_data *hapd);
176 +void hostapd_bss_deinit(struct hostapd_data *hapd);
177 void hostapd_reconfig_encryption(struct hostapd_data *hapd);
178 struct hostapd_data *
179 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
180 @@ -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);
188 --- a/src/drivers/driver_nl80211.c
189 +++ b/src/drivers/driver_nl80211.c
190 @@ -5322,6 +5322,9 @@ static int wpa_driver_nl80211_set_ap(voi
191 if (ret) {
192 wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)",
193 ret, strerror(-ret));
194 + if (!bss->flink->beacon_set)
195 + ret = 0;
196 + bss->flink->beacon_set = 0;
197 } else {
198 link->beacon_set = 1;
199 nl80211_set_bss(bss, params->cts_protect, params->preamble,
200 --- a/hostapd/ctrl_iface.c
201 +++ b/hostapd/ctrl_iface.c
202 @@ -187,7 +187,7 @@ static int hostapd_ctrl_iface_update(str
203 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
213 @@ -410,7 +410,7 @@ static void handle_term(int sig, void *s
214
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 }