hostapd: fix crash regression triggered by mesh mode
[openwrt/staging/mkresin.git] / package / network / services / hostapd / patches / 700-wifi-reload.patch
1 --- a/hostapd/config_file.c
2 +++ b/hostapd/config_file.c
3 @@ -2470,6 +2470,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 --- a/src/ap/ap_config.c
13 +++ b/src/ap/ap_config.c
14 @@ -698,6 +698,7 @@ void hostapd_config_free_bss(struct host
15 os_free(conf->radius_req_attr_sqlite);
16 os_free(conf->rsn_preauth_interfaces);
17 os_free(conf->ctrl_interface);
18 + os_free(conf->config_id);
19 os_free(conf->ca_cert);
20 os_free(conf->server_cert);
21 os_free(conf->server_cert2);
22 --- a/src/ap/ap_config.h
23 +++ b/src/ap/ap_config.h
24 @@ -829,6 +829,7 @@ struct hostapd_bss_config {
25 */
26 u8 mka_psk_set;
27 #endif /* CONFIG_MACSEC */
28 + char *config_id;
29 };
30
31 /**
32 --- a/src/ap/hostapd.c
33 +++ b/src/ap/hostapd.c
34 @@ -242,13 +242,13 @@ int hostapd_reload_config(struct hostapd
35 if (newconf == NULL)
36 return -1;
37
38 - hostapd_clear_old(iface);
39 -
40 oldconf = hapd->iconf;
41 if (hostapd_iface_conf_changed(newconf, oldconf)) {
42 char *fname;
43 int res;
44
45 + hostapd_clear_old(iface);
46 +
47 wpa_printf(MSG_DEBUG,
48 "Configuration changes include interface/BSS modification - force full disable+enable sequence");
49 fname = os_strdup(iface->config_fname);
50 @@ -273,6 +273,22 @@ int hostapd_reload_config(struct hostapd
51 wpa_printf(MSG_ERROR,
52 "Failed to enable interface on config reload");
53 return res;
54 + } else {
55 + for (j = 0; j < iface->num_bss; j++) {
56 + hapd = iface->bss[j];
57 + if (!hapd->config_id || strcmp(hapd->config_id, newconf->bss[j]->config_id)) {
58 + hostapd_flush_old_stations(iface->bss[j],
59 + WLAN_REASON_PREV_AUTH_NOT_VALID);
60 + hostapd_broadcast_wep_clear(iface->bss[j]);
61 +
62 +#ifndef CONFIG_NO_RADIUS
63 + /* TODO: update dynamic data based on changed configuration
64 + * items (e.g., open/close sockets, etc.) */
65 + radius_client_flush(iface->bss[j]->radius, 0);
66 +#endif /* CONFIG_NO_RADIUS */
67 + wpa_printf(MSG_INFO, "bss %d changed", j);
68 + }
69 + }
70 }
71 iface->conf = newconf;
72
73 @@ -289,6 +305,12 @@ int hostapd_reload_config(struct hostapd
74
75 for (j = 0; j < iface->num_bss; j++) {
76 hapd = iface->bss[j];
77 + if (hapd->config_id) {
78 + os_free(hapd->config_id);
79 + hapd->config_id = NULL;
80 + }
81 + if (newconf->bss[j]->config_id)
82 + hapd->config_id = strdup(newconf->bss[j]->config_id);
83 hapd->iconf = newconf;
84 hapd->conf = newconf->bss[j];
85 hostapd_reload_bss(hapd);
86 @@ -2257,6 +2279,10 @@ hostapd_alloc_bss_data(struct hostapd_if
87 hapd->iconf = conf;
88 hapd->conf = bss;
89 hapd->iface = hapd_iface;
90 + if (bss && bss->config_id)
91 + hapd->config_id = strdup(bss->config_id);
92 + else
93 + hapd->config_id = NULL;
94 if (conf)
95 hapd->driver = conf->driver;
96 hapd->ctrl_sock = -1;
97 --- a/src/ap/hostapd.h
98 +++ b/src/ap/hostapd.h
99 @@ -149,6 +149,7 @@ struct hostapd_data {
100 struct hostapd_config *iconf;
101 struct hostapd_bss_config *conf;
102 struct hostapd_ubus_bss ubus;
103 + char *config_id;
104 int interface_added; /* virtual interface added for this BSS */
105 unsigned int started:1;
106 unsigned int disabled:1;
107 --- a/src/drivers/driver_nl80211.c
108 +++ b/src/drivers/driver_nl80211.c
109 @@ -4295,6 +4295,9 @@ static int wpa_driver_nl80211_set_ap(voi
110 if (ret) {
111 wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)",
112 ret, strerror(-ret));
113 + if (!bss->beacon_set)
114 + ret = 0;
115 + bss->beacon_set = 0;
116 } else {
117 bss->beacon_set = 1;
118 nl80211_set_bss(bss, params->cts_protect, params->preamble,