hostapd: update to 2023-03-29
[openwrt/staging/dedeckeh.git] / package / network / services / hostapd / patches / 700-wifi-reload.patch
1 --- a/hostapd/config_file.c
2 +++ b/hostapd/config_file.c
3 @@ -2418,6 +2418,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 @@ -3128,6 +3130,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 @@ -997,6 +997,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 @@ -987,6 +987,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 @@ -254,6 +254,10 @@ static int hostapd_iface_conf_changed(st
44 {
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
54 @@ -267,7 +271,7 @@ static int hostapd_iface_conf_changed(st
55 }
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];
63 @@ -295,6 +299,9 @@ int hostapd_reload_config(struct hostapd
64 char *fname;
65 int res;
66
67 + if (reconf)
68 + return -1;
69 +
70 hostapd_clear_old(iface);
71
72 wpa_printf(MSG_DEBUG,
73 @@ -321,6 +328,24 @@ int hostapd_reload_config(struct hostapd
74 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
98 @@ -337,6 +362,12 @@ int hostapd_reload_config(struct hostapd
99
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);
108 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
112 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;
141 @@ -676,7 +677,7 @@ struct hostapd_iface {
142 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
152 @@ -5054,6 +5054,9 @@ static int wpa_driver_nl80211_set_ap(voi
153 if (ret) {
154 wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)",
155 ret, strerror(-ret));
156 + if (!bss->flink->beacon_set)
157 + ret = 0;
158 + bss->flink->beacon_set = 0;
159 } else {
160 bss->flink->beacon_set = 1;
161 nl80211_set_bss(bss, params->cts_protect, params->preamble,
162 --- a/hostapd/ctrl_iface.c
163 +++ b/hostapd/ctrl_iface.c
164 @@ -187,7 +187,7 @@ static int hostapd_ctrl_iface_update(str
165 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
175 @@ -320,7 +320,7 @@ static void handle_term(int sig, void *s
176
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 }