hostapd: update packaging and patches
[openwrt/openwrt.git] / package / network / services / hostapd / patches / 001-mesh-factor-out-mesh-join-function.patch
1 From 02ae4382f45f772e3630460459eb4e5af64e71b4 Mon Sep 17 00:00:00 2001
2 From: Peter Oh <peter.oh@bowerswilkins.com>
3 Date: Tue, 29 May 2018 14:39:05 -0700
4 Subject: [PATCH 01/18] mesh: factor out mesh join function
5
6 mesh join function consitss of 2 parts which are preparing
7 configurations and sending join event to driver.
8 Since physical mesh join event could happen either right
9 after mesh configuration is done or after CAC is done
10 in case of DFS channel is used, factor out the function
11 into 2 parts to reduce redundant calls.
12
13 Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
14 ---
15 wpa_supplicant/mesh.c | 119 ++++++++++++++++--------------
16 wpa_supplicant/mesh.h | 1 +
17 wpa_supplicant/wpa_supplicant_i.h | 1 +
18 3 files changed, 67 insertions(+), 54 deletions(-)
19
20 --- a/wpa_supplicant/mesh.c
21 +++ b/wpa_supplicant/mesh.c
22 @@ -364,13 +364,48 @@ void wpa_supplicant_mesh_add_scan_ie(str
23 }
24
25
26 +void wpas_join_mesh(struct wpa_supplicant *wpa_s)
27 +{
28 + struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params;
29 + struct wpa_ssid *ssid = wpa_s->current_ssid;
30 + int ret = 0;
31 +
32 + if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
33 + wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
34 + wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
35 + wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
36 + }
37 +
38 + if (wpa_s->ifmsh) {
39 + params->ies = wpa_s->ifmsh->mconf->rsn_ie;
40 + params->ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
41 + params->basic_rates = wpa_s->ifmsh->basic_rates;
42 + params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
43 + params->conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
44 + }
45 +
46 + ret = wpa_drv_join_mesh(wpa_s, params);
47 + if (ret)
48 + wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d\n", ret);
49 +
50 + /* hostapd sets the interface down until we associate */
51 + wpa_drv_set_operstate(wpa_s, 1);
52 +
53 + if (!ret)
54 + wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
55 +
56 + return;
57 +}
58 +
59 +
60 int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
61 struct wpa_ssid *ssid)
62 {
63 - struct wpa_driver_mesh_join_params params;
64 + struct wpa_driver_mesh_join_params *params =
65 + os_zalloc(sizeof(struct wpa_driver_mesh_join_params));
66 int ret = 0;
67
68 - if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency) {
69 + if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency || !params) {
70 ret = -ENOENT;
71 goto out;
72 }
73 @@ -381,22 +416,22 @@ int wpa_supplicant_join_mesh(struct wpa_
74 wpa_s->group_cipher = WPA_CIPHER_NONE;
75 wpa_s->mgmt_group_cipher = 0;
76
77 - os_memset(&params, 0, sizeof(params));
78 - params.meshid = ssid->ssid;
79 - params.meshid_len = ssid->ssid_len;
80 - ibss_mesh_setup_freq(wpa_s, ssid, &params.freq);
81 - wpa_s->mesh_ht_enabled = !!params.freq.ht_enabled;
82 - wpa_s->mesh_vht_enabled = !!params.freq.vht_enabled;
83 - if (params.freq.ht_enabled && params.freq.sec_channel_offset)
84 - ssid->ht40 = params.freq.sec_channel_offset;
85 + params->meshid = ssid->ssid;
86 + params->meshid_len = ssid->ssid_len;
87 + ibss_mesh_setup_freq(wpa_s, ssid, &params->freq);
88 + wpa_s->mesh_ht_enabled = !!params->freq.ht_enabled;
89 + wpa_s->mesh_vht_enabled = !!params->freq.vht_enabled;
90 + if (params->freq.ht_enabled && params->freq.sec_channel_offset)
91 + ssid->ht40 = params->freq.sec_channel_offset;
92 +
93 if (wpa_s->mesh_vht_enabled) {
94 ssid->vht = 1;
95 - switch (params.freq.bandwidth) {
96 + switch (params->freq.bandwidth) {
97 case 80:
98 - if (params.freq.center_freq2) {
99 + if (params->freq.center_freq2) {
100 ssid->max_oper_chwidth = VHT_CHANWIDTH_80P80MHZ;
101 ssid->vht_center_freq2 =
102 - params.freq.center_freq2;
103 + params->freq.center_freq2;
104 } else {
105 ssid->max_oper_chwidth = VHT_CHANWIDTH_80MHZ;
106 }
107 @@ -410,67 +445,43 @@ int wpa_supplicant_join_mesh(struct wpa_
108 }
109 }
110 if (ssid->beacon_int > 0)
111 - params.beacon_int = ssid->beacon_int;
112 + params->beacon_int = ssid->beacon_int;
113 else if (wpa_s->conf->beacon_int > 0)
114 - params.beacon_int = wpa_s->conf->beacon_int;
115 + params->beacon_int = wpa_s->conf->beacon_int;
116 if (ssid->dtim_period > 0)
117 - params.dtim_period = ssid->dtim_period;
118 + params->dtim_period = ssid->dtim_period;
119 else if (wpa_s->conf->dtim_period > 0)
120 - params.dtim_period = wpa_s->conf->dtim_period;
121 - params.conf.max_peer_links = wpa_s->conf->max_peer_links;
122 + params->dtim_period = wpa_s->conf->dtim_period;
123 + params->conf.max_peer_links = wpa_s->conf->max_peer_links;
124 if (ssid->mesh_rssi_threshold < DEFAULT_MESH_RSSI_THRESHOLD) {
125 - params.conf.rssi_threshold = ssid->mesh_rssi_threshold;
126 - params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
127 + params->conf.rssi_threshold = ssid->mesh_rssi_threshold;
128 + params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
129 }
130
131 if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
132 - params.flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
133 - params.flags |= WPA_DRIVER_MESH_FLAG_AMPE;
134 + params->flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
135 + params->flags |= WPA_DRIVER_MESH_FLAG_AMPE;
136 wpa_s->conf->user_mpm = 1;
137 }
138
139 if (wpa_s->conf->user_mpm) {
140 - params.flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
141 - params.conf.auto_plinks = 0;
142 + params->flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
143 + params->conf.auto_plinks = 0;
144 } else {
145 - params.flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
146 - params.conf.auto_plinks = 1;
147 + params->flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
148 + params->conf.auto_plinks = 1;
149 }
150 - params.conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
151 + params->conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
152
153 - if (wpa_supplicant_mesh_init(wpa_s, ssid, &params.freq)) {
154 + wpa_s->mesh_params = params;
155 + if (wpa_supplicant_mesh_init(wpa_s, ssid, &params->freq)) {
156 wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh");
157 wpa_drv_leave_mesh(wpa_s);
158 ret = -1;
159 goto out;
160 }
161
162 - if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
163 - wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
164 - wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
165 - wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
166 - }
167 -
168 - if (wpa_s->ifmsh) {
169 - params.ies = wpa_s->ifmsh->mconf->rsn_ie;
170 - params.ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
171 - params.basic_rates = wpa_s->ifmsh->basic_rates;
172 - params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
173 - params.conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
174 - }
175 -
176 - wpa_msg(wpa_s, MSG_INFO, "joining mesh %s",
177 - wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
178 - ret = wpa_drv_join_mesh(wpa_s, &params);
179 - if (ret)
180 - wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d", ret);
181 -
182 - /* hostapd sets the interface down until we associate */
183 - wpa_drv_set_operstate(wpa_s, 1);
184 -
185 - if (!ret)
186 - wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
187 -
188 + wpas_join_mesh(wpa_s);
189 out:
190 return ret;
191 }
192 --- a/wpa_supplicant/mesh.h
193 +++ b/wpa_supplicant/mesh.h
194 @@ -21,6 +21,7 @@ int wpas_mesh_add_interface(struct wpa_s
195 int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr);
196 int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
197 int duration);
198 +void wpas_join_mesh(struct wpa_supplicant *wpa_s);
199
200 #ifdef CONFIG_MESH
201
202 --- a/wpa_supplicant/wpa_supplicant_i.h
203 +++ b/wpa_supplicant/wpa_supplicant_i.h
204 @@ -810,6 +810,7 @@ struct wpa_supplicant {
205 unsigned int mesh_if_created:1;
206 unsigned int mesh_ht_enabled:1;
207 unsigned int mesh_vht_enabled:1;
208 + struct wpa_driver_mesh_join_params *mesh_params;
209 #ifdef CONFIG_PMKSA_CACHE_EXTERNAL
210 /* struct external_pmksa_cache::list */
211 struct dl_list mesh_external_pmksa_cache;