1 From 91c0f3f6a9ecae3c9106bef8a8606fab0792dd28 Mon Sep 17 00:00:00 2001
2 From: Peter Oh <peter.oh@bowerswilkins.com>
3 Date: Thu, 12 Apr 2018 02:48:58 -0700
4 Subject: [PATCH 01/15] mesh: factor out mesh join function
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.
13 Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
15 wpa_supplicant/mesh.c | 120 ++++++++++++++++--------------
16 wpa_supplicant/mesh.h | 1 +
17 wpa_supplicant/wpa_supplicant_i.h | 1 +
18 3 files changed, 68 insertions(+), 54 deletions(-)
20 --- a/wpa_supplicant/mesh.c
21 +++ b/wpa_supplicant/mesh.c
26 +#include "drivers/driver_nl80211.h"
29 static void wpa_supplicant_mesh_deinit(struct wpa_supplicant *wpa_s)
30 @@ -359,13 +360,48 @@ void wpa_supplicant_mesh_add_scan_ie(str
34 +void wpas_join_mesh(struct wpa_supplicant *wpa_s)
36 + struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params;
37 + struct wpa_ssid *ssid = wpa_s->current_ssid;
40 + if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
41 + wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
42 + wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
43 + wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
47 + params->ies = wpa_s->ifmsh->mconf->rsn_ie;
48 + params->ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
49 + params->basic_rates = wpa_s->ifmsh->basic_rates;
50 + params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
51 + params->conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
54 + ret = wpa_drv_join_mesh(wpa_s, params);
56 + wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d\n", ret);
58 + /* hostapd sets the interface down until we associate */
59 + wpa_drv_set_operstate(wpa_s, 1);
62 + wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
68 int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
69 struct wpa_ssid *ssid)
71 - struct wpa_driver_mesh_join_params params;
72 + struct wpa_driver_mesh_join_params *params =
73 + os_zalloc(sizeof(struct wpa_driver_mesh_join_params));
76 - if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency) {
77 + if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency || !params) {
81 @@ -376,22 +412,22 @@ int wpa_supplicant_join_mesh(struct wpa_
82 wpa_s->group_cipher = WPA_CIPHER_NONE;
83 wpa_s->mgmt_group_cipher = 0;
85 - os_memset(¶ms, 0, sizeof(params));
86 - params.meshid = ssid->ssid;
87 - params.meshid_len = ssid->ssid_len;
88 - ibss_mesh_setup_freq(wpa_s, ssid, ¶ms.freq);
89 - wpa_s->mesh_ht_enabled = !!params.freq.ht_enabled;
90 - wpa_s->mesh_vht_enabled = !!params.freq.vht_enabled;
91 - if (params.freq.ht_enabled && params.freq.sec_channel_offset)
92 - ssid->ht40 = params.freq.sec_channel_offset;
93 + params->meshid = ssid->ssid;
94 + params->meshid_len = ssid->ssid_len;
95 + ibss_mesh_setup_freq(wpa_s, ssid, ¶ms->freq);
96 + wpa_s->mesh_ht_enabled = !!params->freq.ht_enabled;
97 + wpa_s->mesh_vht_enabled = !!params->freq.vht_enabled;
98 + if (params->freq.ht_enabled && params->freq.sec_channel_offset)
99 + ssid->ht40 = params->freq.sec_channel_offset;
101 if (wpa_s->mesh_vht_enabled) {
103 - switch (params.freq.bandwidth) {
104 + switch (params->freq.bandwidth) {
106 - if (params.freq.center_freq2) {
107 + if (params->freq.center_freq2) {
108 ssid->max_oper_chwidth = VHT_CHANWIDTH_80P80MHZ;
109 ssid->vht_center_freq2 =
110 - params.freq.center_freq2;
111 + params->freq.center_freq2;
113 ssid->max_oper_chwidth = VHT_CHANWIDTH_80MHZ;
115 @@ -405,67 +441,43 @@ int wpa_supplicant_join_mesh(struct wpa_
118 if (ssid->beacon_int > 0)
119 - params.beacon_int = ssid->beacon_int;
120 + params->beacon_int = ssid->beacon_int;
121 else if (wpa_s->conf->beacon_int > 0)
122 - params.beacon_int = wpa_s->conf->beacon_int;
123 + params->beacon_int = wpa_s->conf->beacon_int;
124 if (ssid->dtim_period > 0)
125 - params.dtim_period = ssid->dtim_period;
126 + params->dtim_period = ssid->dtim_period;
127 else if (wpa_s->conf->dtim_period > 0)
128 - params.dtim_period = wpa_s->conf->dtim_period;
129 - params.conf.max_peer_links = wpa_s->conf->max_peer_links;
130 + params->dtim_period = wpa_s->conf->dtim_period;
131 + params->conf.max_peer_links = wpa_s->conf->max_peer_links;
132 if (ssid->mesh_rssi_threshold < DEFAULT_MESH_RSSI_THRESHOLD) {
133 - params.conf.rssi_threshold = ssid->mesh_rssi_threshold;
134 - params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
135 + params->conf.rssi_threshold = ssid->mesh_rssi_threshold;
136 + params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
139 if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
140 - params.flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
141 - params.flags |= WPA_DRIVER_MESH_FLAG_AMPE;
142 + params->flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
143 + params->flags |= WPA_DRIVER_MESH_FLAG_AMPE;
144 wpa_s->conf->user_mpm = 1;
147 if (wpa_s->conf->user_mpm) {
148 - params.flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
149 - params.conf.auto_plinks = 0;
150 + params->flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
151 + params->conf.auto_plinks = 0;
153 - params.flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
154 - params.conf.auto_plinks = 1;
155 + params->flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
156 + params->conf.auto_plinks = 1;
158 - params.conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
159 + params->conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
161 - if (wpa_supplicant_mesh_init(wpa_s, ssid, ¶ms.freq)) {
162 + wpa_s->mesh_params = params;
163 + if (wpa_supplicant_mesh_init(wpa_s, ssid, ¶ms->freq)) {
164 wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh");
165 wpa_drv_leave_mesh(wpa_s);
170 - if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
171 - wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
172 - wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
173 - wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
176 - if (wpa_s->ifmsh) {
177 - params.ies = wpa_s->ifmsh->mconf->rsn_ie;
178 - params.ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
179 - params.basic_rates = wpa_s->ifmsh->basic_rates;
180 - params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
181 - params.conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
184 - wpa_msg(wpa_s, MSG_INFO, "joining mesh %s",
185 - wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
186 - ret = wpa_drv_join_mesh(wpa_s, ¶ms);
188 - wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d", ret);
190 - /* hostapd sets the interface down until we associate */
191 - wpa_drv_set_operstate(wpa_s, 1);
194 - wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
196 + wpas_join_mesh(wpa_s);
200 --- a/wpa_supplicant/mesh.h
201 +++ b/wpa_supplicant/mesh.h
202 @@ -21,6 +21,7 @@ int wpas_mesh_add_interface(struct wpa_s
203 int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr);
204 int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
206 +void wpas_join_mesh(struct wpa_supplicant *wpa_s);
210 --- a/wpa_supplicant/wpa_supplicant_i.h
211 +++ b/wpa_supplicant/wpa_supplicant_i.h
212 @@ -810,6 +810,7 @@ struct wpa_supplicant {
213 unsigned int mesh_if_created:1;
214 unsigned int mesh_ht_enabled:1;
215 unsigned int mesh_vht_enabled:1;
216 + struct wpa_driver_mesh_join_params *mesh_params;
217 #ifdef CONFIG_PMKSA_CACHE_EXTERNAL
218 /* struct external_pmksa_cache::list */
219 struct dl_list mesh_external_pmksa_cache;