blob: b6a5e8857db9aaa4dc8f68f3735cf3dd78ae06f6 [file] [log] [blame]
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001/*
2 * WPA Supplicant - Basic mesh peer management
3 * Copyright (c) 2013-2014, cozybit, Inc. All rights reserved.
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9#include "utils/includes.h"
10
11#include "utils/common.h"
12#include "utils/eloop.h"
13#include "common/ieee802_11_defs.h"
Paul Stewart092955c2017-02-06 09:13:09 -080014#include "common/hw_features_common.h"
Hai Shalom74f70d42019-02-11 14:42:39 -080015#include "common/ocv.h"
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080016#include "ap/hostapd.h"
17#include "ap/sta_info.h"
18#include "ap/ieee802_11.h"
Dmitry Shmidte4663042016-04-04 10:07:49 -070019#include "ap/wpa_auth.h"
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080020#include "wpa_supplicant_i.h"
21#include "driver_i.h"
22#include "mesh_mpm.h"
23#include "mesh_rsn.h"
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070024#include "notify.h"
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080025
26struct mesh_peer_mgmt_ie {
Dmitry Shmidt014a3ff2015-12-28 13:27:49 -080027 const u8 *proto_id; /* Mesh Peering Protocol Identifier (2 octets) */
28 const u8 *llid; /* Local Link ID (2 octets) */
29 const u8 *plid; /* Peer Link ID (conditional, 2 octets) */
30 const u8 *reason; /* Reason Code (conditional, 2 octets) */
31 const u8 *chosen_pmk; /* Chosen PMK (optional, 16 octets) */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080032};
33
34static void plink_timer(void *eloop_ctx, void *user_data);
35
36
37enum plink_event {
38 PLINK_UNDEFINED,
39 OPN_ACPT,
40 OPN_RJCT,
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080041 CNF_ACPT,
42 CNF_RJCT,
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080043 CLS_ACPT,
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -070044 REQ_RJCT
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080045};
46
47static const char * const mplstate[] = {
Dmitry Shmidtde47be72016-01-07 12:52:55 -080048 [0] = "UNINITIALIZED",
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -070049 [PLINK_IDLE] = "IDLE",
50 [PLINK_OPN_SNT] = "OPN_SNT",
51 [PLINK_OPN_RCVD] = "OPN_RCVD",
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080052 [PLINK_CNF_RCVD] = "CNF_RCVD",
53 [PLINK_ESTAB] = "ESTAB",
54 [PLINK_HOLDING] = "HOLDING",
55 [PLINK_BLOCKED] = "BLOCKED"
56};
57
58static const char * const mplevent[] = {
59 [PLINK_UNDEFINED] = "UNDEFINED",
60 [OPN_ACPT] = "OPN_ACPT",
61 [OPN_RJCT] = "OPN_RJCT",
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080062 [CNF_ACPT] = "CNF_ACPT",
63 [CNF_RJCT] = "CNF_RJCT",
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080064 [CLS_ACPT] = "CLS_ACPT",
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -070065 [REQ_RJCT] = "REQ_RJCT",
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080066};
67
68
69static int mesh_mpm_parse_peer_mgmt(struct wpa_supplicant *wpa_s,
70 u8 action_field,
71 const u8 *ie, size_t len,
72 struct mesh_peer_mgmt_ie *mpm_ie)
73{
74 os_memset(mpm_ie, 0, sizeof(*mpm_ie));
75
Dmitry Shmidt014a3ff2015-12-28 13:27:49 -080076 /* Remove optional Chosen PMK field at end */
77 if (len >= SAE_PMKID_LEN) {
78 mpm_ie->chosen_pmk = ie + len - SAE_PMKID_LEN;
79 len -= SAE_PMKID_LEN;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080080 }
81
82 if ((action_field == PLINK_OPEN && len != 4) ||
83 (action_field == PLINK_CONFIRM && len != 6) ||
84 (action_field == PLINK_CLOSE && len != 6 && len != 8)) {
85 wpa_msg(wpa_s, MSG_DEBUG, "MPM: Invalid peer mgmt ie");
86 return -1;
87 }
88
89 /* required fields */
90 if (len < 4)
91 return -1;
92 mpm_ie->proto_id = ie;
93 mpm_ie->llid = ie + 2;
94 ie += 4;
95 len -= 4;
96
97 /* close reason is always present at end for close */
98 if (action_field == PLINK_CLOSE) {
99 if (len < 2)
100 return -1;
101 mpm_ie->reason = ie + len - 2;
102 len -= 2;
103 }
104
Dmitry Shmidt014a3ff2015-12-28 13:27:49 -0800105 /* Peer Link ID, present for confirm, and possibly close */
106 if (len >= 2)
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800107 mpm_ie->plid = ie;
108
109 return 0;
110}
111
112
113static int plink_free_count(struct hostapd_data *hapd)
114{
115 if (hapd->max_plinks > hapd->num_plinks)
116 return hapd->max_plinks - hapd->num_plinks;
117 return 0;
118}
119
120
121static u16 copy_supp_rates(struct wpa_supplicant *wpa_s,
122 struct sta_info *sta,
123 struct ieee802_11_elems *elems)
124{
125 if (!elems->supp_rates) {
126 wpa_msg(wpa_s, MSG_ERROR, "no supported rates from " MACSTR,
127 MAC2STR(sta->addr));
128 return WLAN_STATUS_UNSPECIFIED_FAILURE;
129 }
130
131 if (elems->supp_rates_len + elems->ext_supp_rates_len >
132 sizeof(sta->supported_rates)) {
133 wpa_msg(wpa_s, MSG_ERROR,
134 "Invalid supported rates element length " MACSTR
135 " %d+%d", MAC2STR(sta->addr), elems->supp_rates_len,
136 elems->ext_supp_rates_len);
137 return WLAN_STATUS_UNSPECIFIED_FAILURE;
138 }
139
140 sta->supported_rates_len = merge_byte_arrays(
141 sta->supported_rates, sizeof(sta->supported_rates),
142 elems->supp_rates, elems->supp_rates_len,
143 elems->ext_supp_rates, elems->ext_supp_rates_len);
144
145 return WLAN_STATUS_SUCCESS;
146}
147
148
149/* return true if elems from a neighbor match this MBSS */
Hai Shalome21d4e82020-04-29 16:34:06 -0700150static bool matches_local(struct wpa_supplicant *wpa_s,
151 struct ieee802_11_elems *elems)
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800152{
153 struct mesh_conf *mconf = wpa_s->ifmsh->mconf;
154
155 if (elems->mesh_config_len < 5)
Hai Shalome21d4e82020-04-29 16:34:06 -0700156 return false;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800157
158 return (mconf->meshid_len == elems->mesh_id_len &&
159 os_memcmp(mconf->meshid, elems->mesh_id,
160 elems->mesh_id_len) == 0 &&
161 mconf->mesh_pp_id == elems->mesh_config[0] &&
162 mconf->mesh_pm_id == elems->mesh_config[1] &&
163 mconf->mesh_cc_id == elems->mesh_config[2] &&
164 mconf->mesh_sp_id == elems->mesh_config[3] &&
165 mconf->mesh_auth_id == elems->mesh_config[4]);
166}
167
168
169/* check if local link id is already used with another peer */
Hai Shalome21d4e82020-04-29 16:34:06 -0700170static bool llid_in_use(struct wpa_supplicant *wpa_s, u16 llid)
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800171{
172 struct sta_info *sta;
173 struct hostapd_data *hapd = wpa_s->ifmsh->bss[0];
174
175 for (sta = hapd->sta_list; sta; sta = sta->next) {
176 if (sta->my_lid == llid)
Hai Shalome21d4e82020-04-29 16:34:06 -0700177 return true;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800178 }
179
Hai Shalome21d4e82020-04-29 16:34:06 -0700180 return false;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800181}
182
183
184/* generate an llid for a link and set to initial state */
185static void mesh_mpm_init_link(struct wpa_supplicant *wpa_s,
186 struct sta_info *sta)
187{
188 u16 llid;
189
190 do {
191 if (os_get_random((u8 *) &llid, sizeof(llid)) < 0)
Hai Shalom5f92bc92019-04-18 11:54:11 -0700192 llid = 0; /* continue */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800193 } while (!llid || llid_in_use(wpa_s, llid));
194
195 sta->my_lid = llid;
196 sta->peer_lid = 0;
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700197 sta->peer_aid = 0;
Dmitry Shmidt216983b2015-02-06 10:50:36 -0800198
199 /*
200 * We do not use wpa_mesh_set_plink_state() here because there is no
201 * entry in kernel yet.
202 */
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700203 sta->plink_state = PLINK_IDLE;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800204}
205
206
207static void mesh_mpm_send_plink_action(struct wpa_supplicant *wpa_s,
208 struct sta_info *sta,
209 enum plink_action_field type,
210 u16 close_reason)
211{
212 struct wpabuf *buf;
213 struct hostapd_iface *ifmsh = wpa_s->ifmsh;
214 struct hostapd_data *bss = ifmsh->bss[0];
215 struct mesh_conf *conf = ifmsh->mconf;
216 u8 supp_rates[2 + 2 + 32];
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800217 u8 *pos, *cat;
218 u8 ie_len, add_plid = 0;
219 int ret;
220 int ampe = conf->security & MESH_CONF_SEC_AMPE;
221 size_t buf_len;
222
223 if (!sta)
224 return;
225
Hai Shalom74f70d42019-02-11 14:42:39 -0800226 buf_len = 2 + /* Category and Action */
227 2 + /* capability info */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800228 2 + /* AID */
229 2 + 8 + /* supported rates */
230 2 + (32 - 8) +
231 2 + 32 + /* mesh ID */
232 2 + 7 + /* mesh config */
Hai Shalom74f70d42019-02-11 14:42:39 -0800233 2 + 24 + /* peering management */
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800234 2 + 96 + 32 + 32 + /* AMPE (96 + max GTKlen + max IGTKlen) */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800235 2 + 16; /* MIC */
Dmitry Shmidtff787d52015-01-12 13:01:47 -0800236 if (type != PLINK_CLOSE && wpa_s->mesh_ht_enabled) {
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800237 buf_len += 2 + 26 + /* HT capabilities */
238 2 + 22; /* HT operation */
239 }
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800240#ifdef CONFIG_IEEE80211AC
241 if (type != PLINK_CLOSE && wpa_s->mesh_vht_enabled) {
242 buf_len += 2 + 12 + /* VHT Capabilities */
243 2 + 5; /* VHT Operation */
244 }
245#endif /* CONFIG_IEEE80211AC */
Hai Shalom81f62d82019-07-22 12:10:00 -0700246#ifdef CONFIG_IEEE80211AX
247 if (type != PLINK_CLOSE && wpa_s->mesh_he_enabled) {
248 buf_len += 3 +
249 HE_MAX_MAC_CAPAB_SIZE +
250 HE_MAX_PHY_CAPAB_SIZE +
251 HE_MAX_MCS_CAPAB_SIZE +
252 HE_MAX_PPET_CAPAB_SIZE;
253 buf_len += 3 + sizeof(struct ieee80211_he_operation);
254 }
255#endif /* CONFIG_IEEE80211AX */
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800256 if (type != PLINK_CLOSE)
257 buf_len += conf->rsn_ie_len; /* RSN IE */
Hai Shalom74f70d42019-02-11 14:42:39 -0800258#ifdef CONFIG_OCV
259 /* OCI is included even when the other STA doesn't support OCV */
260 if (type != PLINK_CLOSE && conf->ocv)
261 buf_len += OCV_OCI_EXTENDED_LEN;
262#endif /* CONFIG_OCV */
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800263
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800264 buf = wpabuf_alloc(buf_len);
265 if (!buf)
266 return;
267
268 cat = wpabuf_mhead_u8(buf);
269 wpabuf_put_u8(buf, WLAN_ACTION_SELF_PROTECTED);
270 wpabuf_put_u8(buf, type);
271
272 if (type != PLINK_CLOSE) {
273 u8 info;
274
275 /* capability info */
276 wpabuf_put_le16(buf, ampe ? IEEE80211_CAP_PRIVACY : 0);
277
278 /* aid */
279 if (type == PLINK_CONFIRM)
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800280 wpabuf_put_le16(buf, sta->aid);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800281
282 /* IE: supp + ext. supp rates */
283 pos = hostapd_eid_supp_rates(bss, supp_rates);
284 pos = hostapd_eid_ext_supp_rates(bss, pos);
285 wpabuf_put_data(buf, supp_rates, pos - supp_rates);
286
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800287 /* IE: RSN IE */
288 wpabuf_put_data(buf, conf->rsn_ie, conf->rsn_ie_len);
289
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800290 /* IE: Mesh ID */
291 wpabuf_put_u8(buf, WLAN_EID_MESH_ID);
292 wpabuf_put_u8(buf, conf->meshid_len);
293 wpabuf_put_data(buf, conf->meshid, conf->meshid_len);
294
295 /* IE: mesh conf */
296 wpabuf_put_u8(buf, WLAN_EID_MESH_CONFIG);
297 wpabuf_put_u8(buf, 7);
298 wpabuf_put_u8(buf, conf->mesh_pp_id);
299 wpabuf_put_u8(buf, conf->mesh_pm_id);
300 wpabuf_put_u8(buf, conf->mesh_cc_id);
301 wpabuf_put_u8(buf, conf->mesh_sp_id);
302 wpabuf_put_u8(buf, conf->mesh_auth_id);
303 info = (bss->num_plinks > 63 ? 63 : bss->num_plinks) << 1;
304 /* TODO: Add Connected to Mesh Gate/AS subfields */
305 wpabuf_put_u8(buf, info);
306 /* always forwarding & accepting plinks for now */
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700307 wpabuf_put_u8(buf, MESH_CAP_ACCEPT_ADDITIONAL_PEER |
308 MESH_CAP_FORWARDING);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800309 } else { /* Peer closing frame */
310 /* IE: Mesh ID */
311 wpabuf_put_u8(buf, WLAN_EID_MESH_ID);
312 wpabuf_put_u8(buf, conf->meshid_len);
313 wpabuf_put_data(buf, conf->meshid, conf->meshid_len);
314 }
315
316 /* IE: Mesh Peering Management element */
317 ie_len = 4;
318 if (ampe)
319 ie_len += PMKID_LEN;
320 switch (type) {
321 case PLINK_OPEN:
322 break;
323 case PLINK_CONFIRM:
324 ie_len += 2;
325 add_plid = 1;
326 break;
327 case PLINK_CLOSE:
328 ie_len += 2;
329 add_plid = 1;
330 ie_len += 2; /* reason code */
331 break;
332 }
333
334 wpabuf_put_u8(buf, WLAN_EID_PEER_MGMT);
335 wpabuf_put_u8(buf, ie_len);
336 /* peering protocol */
337 if (ampe)
338 wpabuf_put_le16(buf, 1);
339 else
340 wpabuf_put_le16(buf, 0);
341 wpabuf_put_le16(buf, sta->my_lid);
342 if (add_plid)
343 wpabuf_put_le16(buf, sta->peer_lid);
344 if (type == PLINK_CLOSE)
345 wpabuf_put_le16(buf, close_reason);
346 if (ampe) {
347 if (sta->sae == NULL) {
348 wpa_msg(wpa_s, MSG_INFO, "Mesh MPM: no SAE session");
349 goto fail;
350 }
351 mesh_rsn_get_pmkid(wpa_s->mesh_rsn, sta,
352 wpabuf_put(buf, PMKID_LEN));
353 }
354
Dmitry Shmidtff787d52015-01-12 13:01:47 -0800355 if (type != PLINK_CLOSE && wpa_s->mesh_ht_enabled) {
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800356 u8 ht_capa_oper[2 + 26 + 2 + 22];
357
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800358 pos = hostapd_eid_ht_capabilities(bss, ht_capa_oper);
359 pos = hostapd_eid_ht_operation(bss, pos);
360 wpabuf_put_data(buf, ht_capa_oper, pos - ht_capa_oper);
361 }
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800362#ifdef CONFIG_IEEE80211AC
363 if (type != PLINK_CLOSE && wpa_s->mesh_vht_enabled) {
364 u8 vht_capa_oper[2 + 12 + 2 + 5];
365
Dmitry Shmidt7d175302016-09-06 13:11:34 -0700366 pos = hostapd_eid_vht_capabilities(bss, vht_capa_oper, 0);
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800367 pos = hostapd_eid_vht_operation(bss, pos);
368 wpabuf_put_data(buf, vht_capa_oper, pos - vht_capa_oper);
369 }
370#endif /* CONFIG_IEEE80211AC */
Hai Shalom81f62d82019-07-22 12:10:00 -0700371#ifdef CONFIG_IEEE80211AX
372 if (type != PLINK_CLOSE && wpa_s->mesh_he_enabled) {
373 u8 he_capa_oper[3 +
374 HE_MAX_MAC_CAPAB_SIZE +
375 HE_MAX_PHY_CAPAB_SIZE +
376 HE_MAX_MCS_CAPAB_SIZE +
377 HE_MAX_PPET_CAPAB_SIZE +
378 3 + sizeof(struct ieee80211_he_operation)];
379
380 pos = hostapd_eid_he_capab(bss, he_capa_oper,
381 IEEE80211_MODE_MESH);
382 pos = hostapd_eid_he_operation(bss, pos);
383 wpabuf_put_data(buf, he_capa_oper, pos - he_capa_oper);
384 }
385#endif /* CONFIG_IEEE80211AX */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800386
Hai Shalom74f70d42019-02-11 14:42:39 -0800387#ifdef CONFIG_OCV
388 if (type != PLINK_CLOSE && conf->ocv) {
389 struct wpa_channel_info ci;
390
391 if (wpa_drv_channel_info(wpa_s, &ci) != 0) {
392 wpa_printf(MSG_WARNING,
393 "Mesh MPM: Failed to get channel info for OCI element");
394 goto fail;
395 }
396
397 pos = wpabuf_put(buf, OCV_OCI_EXTENDED_LEN);
398 if (ocv_insert_extended_oci(&ci, pos) < 0)
399 goto fail;
400 }
401#endif /* CONFIG_OCV */
402
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800403 if (ampe && mesh_rsn_protect_frame(wpa_s->mesh_rsn, sta, cat, buf)) {
404 wpa_msg(wpa_s, MSG_INFO,
405 "Mesh MPM: failed to add AMPE and MIC IE");
406 goto fail;
407 }
408
Dmitry Shmidtde47be72016-01-07 12:52:55 -0800409 wpa_msg(wpa_s, MSG_DEBUG, "Mesh MPM: Sending peering frame type %d to "
410 MACSTR " (my_lid=0x%x peer_lid=0x%x)",
411 type, MAC2STR(sta->addr), sta->my_lid, sta->peer_lid);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800412 ret = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0,
413 sta->addr, wpa_s->own_addr, wpa_s->own_addr,
414 wpabuf_head(buf), wpabuf_len(buf), 0);
415 if (ret < 0)
416 wpa_msg(wpa_s, MSG_INFO,
417 "Mesh MPM: failed to send peering frame");
418
419fail:
420 wpabuf_free(buf);
421}
422
423
424/* configure peering state in ours and driver's station entry */
Dmitry Shmidt216983b2015-02-06 10:50:36 -0800425void wpa_mesh_set_plink_state(struct wpa_supplicant *wpa_s,
426 struct sta_info *sta,
427 enum mesh_plink_state state)
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800428{
429 struct hostapd_sta_add_params params;
430 int ret;
431
Dmitry Shmidtde47be72016-01-07 12:52:55 -0800432 wpa_msg(wpa_s, MSG_DEBUG, "MPM set " MACSTR " from %s into %s",
433 MAC2STR(sta->addr), mplstate[sta->plink_state],
434 mplstate[state]);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800435 sta->plink_state = state;
436
437 os_memset(&params, 0, sizeof(params));
438 params.addr = sta->addr;
439 params.plink_state = state;
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700440 params.peer_aid = sta->peer_aid;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800441 params.set = 1;
442
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800443 ret = wpa_drv_sta_add(wpa_s, &params);
444 if (ret) {
445 wpa_msg(wpa_s, MSG_ERROR, "Driver failed to set " MACSTR
446 ": %d", MAC2STR(sta->addr), ret);
447 }
448}
449
450
451static void mesh_mpm_fsm_restart(struct wpa_supplicant *wpa_s,
452 struct sta_info *sta)
453{
454 struct hostapd_data *hapd = wpa_s->ifmsh->bss[0];
455
456 eloop_cancel_timeout(plink_timer, wpa_s, sta);
457
Dmitry Shmidt216983b2015-02-06 10:50:36 -0800458 ap_free_sta(hapd, sta);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800459}
460
461
462static void plink_timer(void *eloop_ctx, void *user_data)
463{
464 struct wpa_supplicant *wpa_s = eloop_ctx;
465 struct sta_info *sta = user_data;
466 u16 reason = 0;
467 struct mesh_conf *conf = wpa_s->ifmsh->mconf;
Dmitry Shmidte4663042016-04-04 10:07:49 -0700468 struct hostapd_data *hapd = wpa_s->ifmsh->bss[0];
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800469
470 switch (sta->plink_state) {
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700471 case PLINK_OPN_RCVD:
472 case PLINK_OPN_SNT:
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800473 /* retry timer */
474 if (sta->mpm_retries < conf->dot11MeshMaxRetries) {
475 eloop_register_timeout(
476 conf->dot11MeshRetryTimeout / 1000,
477 (conf->dot11MeshRetryTimeout % 1000) * 1000,
478 plink_timer, wpa_s, sta);
479 mesh_mpm_send_plink_action(wpa_s, sta, PLINK_OPEN, 0);
480 sta->mpm_retries++;
481 break;
482 }
483 reason = WLAN_REASON_MESH_MAX_RETRIES;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700484 /* fall through */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800485
486 case PLINK_CNF_RCVD:
487 /* confirm timer */
488 if (!reason)
489 reason = WLAN_REASON_MESH_CONFIRM_TIMEOUT;
Dmitry Shmidt216983b2015-02-06 10:50:36 -0800490 wpa_mesh_set_plink_state(wpa_s, sta, PLINK_HOLDING);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800491 eloop_register_timeout(conf->dot11MeshHoldingTimeout / 1000,
492 (conf->dot11MeshHoldingTimeout % 1000) * 1000,
493 plink_timer, wpa_s, sta);
494 mesh_mpm_send_plink_action(wpa_s, sta, PLINK_CLOSE, reason);
495 break;
496 case PLINK_HOLDING:
497 /* holding timer */
Dmitry Shmidte4663042016-04-04 10:07:49 -0700498
499 if (sta->mesh_sae_pmksa_caching) {
500 wpa_printf(MSG_DEBUG, "MPM: Peer " MACSTR
501 " looks like it does not support mesh SAE PMKSA caching, so remove the cached entry for it",
502 MAC2STR(sta->addr));
503 wpa_auth_pmksa_remove(hapd->wpa_auth, sta->addr);
504 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800505 mesh_mpm_fsm_restart(wpa_s, sta);
506 break;
507 default:
508 break;
509 }
510}
511
512
513/* initiate peering with station */
514static void
515mesh_mpm_plink_open(struct wpa_supplicant *wpa_s, struct sta_info *sta,
516 enum mesh_plink_state next_state)
517{
518 struct mesh_conf *conf = wpa_s->ifmsh->mconf;
519
520 eloop_cancel_timeout(plink_timer, wpa_s, sta);
521 eloop_register_timeout(conf->dot11MeshRetryTimeout / 1000,
522 (conf->dot11MeshRetryTimeout % 1000) * 1000,
523 plink_timer, wpa_s, sta);
524 mesh_mpm_send_plink_action(wpa_s, sta, PLINK_OPEN, 0);
525 wpa_mesh_set_plink_state(wpa_s, sta, next_state);
526}
527
528
Dmitry Shmidte4663042016-04-04 10:07:49 -0700529static int mesh_mpm_plink_close(struct hostapd_data *hapd, struct sta_info *sta,
530 void *ctx)
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800531{
532 struct wpa_supplicant *wpa_s = ctx;
533 int reason = WLAN_REASON_MESH_PEERING_CANCELLED;
534
535 if (sta) {
Hai Shalom899fcc72020-10-19 14:38:18 -0700536 if (sta->plink_state == PLINK_ESTAB)
537 hapd->num_plinks--;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800538 wpa_mesh_set_plink_state(wpa_s, sta, PLINK_HOLDING);
539 mesh_mpm_send_plink_action(wpa_s, sta, PLINK_CLOSE, reason);
540 wpa_printf(MSG_DEBUG, "MPM closing plink sta=" MACSTR,
541 MAC2STR(sta->addr));
542 eloop_cancel_timeout(plink_timer, wpa_s, sta);
Hai Shalom899fcc72020-10-19 14:38:18 -0700543 eloop_cancel_timeout(mesh_auth_timer, wpa_s, sta);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800544 return 0;
545 }
546
547 return 1;
548}
549
550
Dmitry Shmidte4663042016-04-04 10:07:49 -0700551int mesh_mpm_close_peer(struct wpa_supplicant *wpa_s, const u8 *addr)
552{
553 struct hostapd_data *hapd;
554 struct sta_info *sta;
555
556 if (!wpa_s->ifmsh) {
557 wpa_msg(wpa_s, MSG_INFO, "Mesh is not prepared yet");
558 return -1;
559 }
560
561 hapd = wpa_s->ifmsh->bss[0];
562 sta = ap_get_sta(hapd, addr);
563 if (!sta) {
564 wpa_msg(wpa_s, MSG_INFO, "No such mesh peer");
565 return -1;
566 }
567
568 return mesh_mpm_plink_close(hapd, sta, wpa_s) == 0 ? 0 : -1;
569}
570
571
572static void peer_add_timer(void *eloop_ctx, void *user_data)
573{
574 struct wpa_supplicant *wpa_s = eloop_ctx;
575 struct hostapd_data *hapd = wpa_s->ifmsh->bss[0];
576
577 os_memset(hapd->mesh_required_peer, 0, ETH_ALEN);
578}
579
580
581int mesh_mpm_connect_peer(struct wpa_supplicant *wpa_s, const u8 *addr,
582 int duration)
583{
584 struct wpa_ssid *ssid = wpa_s->current_ssid;
585 struct hostapd_data *hapd;
586 struct sta_info *sta;
587 struct mesh_conf *conf;
588
589 if (!wpa_s->ifmsh) {
590 wpa_msg(wpa_s, MSG_INFO, "Mesh is not prepared yet");
591 return -1;
592 }
593
594 if (!ssid || !ssid->no_auto_peer) {
595 wpa_msg(wpa_s, MSG_INFO,
596 "This command is available only with no_auto_peer mesh network");
597 return -1;
598 }
599
600 hapd = wpa_s->ifmsh->bss[0];
601 conf = wpa_s->ifmsh->mconf;
602
603 sta = ap_get_sta(hapd, addr);
604 if (!sta) {
605 wpa_msg(wpa_s, MSG_INFO, "No such mesh peer");
606 return -1;
607 }
608
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700609 if ((PLINK_OPN_SNT <= sta->plink_state &&
Dmitry Shmidte4663042016-04-04 10:07:49 -0700610 sta->plink_state <= PLINK_ESTAB) ||
611 (sta->sae && sta->sae->state > SAE_NOTHING)) {
612 wpa_msg(wpa_s, MSG_INFO,
613 "Specified peer is connecting/connected");
614 return -1;
615 }
616
617 if (conf->security == MESH_CONF_SEC_NONE) {
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700618 mesh_mpm_plink_open(wpa_s, sta, PLINK_OPN_SNT);
Dmitry Shmidte4663042016-04-04 10:07:49 -0700619 } else {
620 mesh_rsn_auth_sae_sta(wpa_s, sta);
621 os_memcpy(hapd->mesh_required_peer, addr, ETH_ALEN);
622 eloop_register_timeout(duration == -1 ? 10 : duration, 0,
623 peer_add_timer, wpa_s, NULL);
624 }
625
626 return 0;
627}
628
629
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800630void mesh_mpm_deinit(struct wpa_supplicant *wpa_s, struct hostapd_iface *ifmsh)
631{
632 struct hostapd_data *hapd = ifmsh->bss[0];
633
634 /* notify peers we're leaving */
635 ap_for_each_sta(hapd, mesh_mpm_plink_close, wpa_s);
636
637 hapd->num_plinks = 0;
638 hostapd_free_stas(hapd);
Dmitry Shmidte4663042016-04-04 10:07:49 -0700639 eloop_cancel_timeout(peer_add_timer, wpa_s, NULL);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800640}
641
642
643/* for mesh_rsn to indicate this peer has completed authentication, and we're
644 * ready to start AMPE */
645void mesh_mpm_auth_peer(struct wpa_supplicant *wpa_s, const u8 *addr)
646{
647 struct hostapd_data *data = wpa_s->ifmsh->bss[0];
648 struct hostapd_sta_add_params params;
649 struct sta_info *sta;
650 int ret;
651
652 sta = ap_get_sta(data, addr);
653 if (!sta) {
654 wpa_msg(wpa_s, MSG_DEBUG, "no such mesh peer");
655 return;
656 }
657
658 /* TODO: Should do nothing if this STA is already authenticated, but
659 * the AP code already sets this flag. */
660 sta->flags |= WLAN_STA_AUTH;
661
662 mesh_rsn_init_ampe_sta(wpa_s, sta);
663
664 os_memset(&params, 0, sizeof(params));
665 params.addr = sta->addr;
666 params.flags = WPA_STA_AUTHENTICATED | WPA_STA_AUTHORIZED;
667 params.set = 1;
668
669 wpa_msg(wpa_s, MSG_DEBUG, "MPM authenticating " MACSTR,
670 MAC2STR(sta->addr));
671 ret = wpa_drv_sta_add(wpa_s, &params);
672 if (ret) {
673 wpa_msg(wpa_s, MSG_ERROR,
674 "Driver failed to set " MACSTR ": %d",
675 MAC2STR(sta->addr), ret);
676 }
677
678 if (!sta->my_lid)
679 mesh_mpm_init_link(wpa_s, sta);
680
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700681 mesh_mpm_plink_open(wpa_s, sta, PLINK_OPN_SNT);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800682}
683
Dmitry Shmidt216983b2015-02-06 10:50:36 -0800684/*
685 * Initialize a sta_info structure for a peer and upload it into the driver
686 * in preparation for beginning authentication or peering. This is done when a
687 * Beacon (secure or open mesh) or a peering open frame (for open mesh) is
688 * received from the peer for the first time.
689 */
690static struct sta_info * mesh_mpm_add_peer(struct wpa_supplicant *wpa_s,
691 const u8 *addr,
692 struct ieee802_11_elems *elems)
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800693{
694 struct hostapd_sta_add_params params;
695 struct mesh_conf *conf = wpa_s->ifmsh->mconf;
696 struct hostapd_data *data = wpa_s->ifmsh->bss[0];
697 struct sta_info *sta;
Paul Stewart092955c2017-02-06 09:13:09 -0800698 struct ieee80211_ht_operation *oper;
Dmitry Shmidt216983b2015-02-06 10:50:36 -0800699 int ret;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800700
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700701 if (elems->mesh_config_len >= 7 &&
702 !(elems->mesh_config[6] & MESH_CAP_ACCEPT_ADDITIONAL_PEER)) {
703 wpa_msg(wpa_s, MSG_DEBUG,
704 "mesh: Ignore a crowded peer " MACSTR,
705 MAC2STR(addr));
706 return NULL;
707 }
708
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800709 sta = ap_get_sta(data, addr);
Hai Shalomfdcde762020-04-02 11:19:20 -0700710 if (sta)
711 return NULL;
712
713 sta = ap_sta_add(data, addr);
714 if (!sta)
715 return NULL;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800716
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800717 /* Set WMM by default since Mesh STAs are QoS STAs */
718 sta->flags |= WLAN_STA_WMM;
719
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800720 /* initialize sta */
Dmitry Shmidt216983b2015-02-06 10:50:36 -0800721 if (copy_supp_rates(wpa_s, sta, elems)) {
722 ap_free_sta(data, sta);
723 return NULL;
724 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800725
Dmitry Shmidtde47be72016-01-07 12:52:55 -0800726 if (!sta->my_lid)
727 mesh_mpm_init_link(wpa_s, sta);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800728
Dmitry Shmidt9d9e6022015-04-23 10:34:55 -0700729 copy_sta_ht_capab(data, sta, elems->ht_capabilities);
Paul Stewart092955c2017-02-06 09:13:09 -0800730
731 oper = (struct ieee80211_ht_operation *) elems->ht_operation;
732 if (oper &&
Dmitry Shmidtebd93af2017-02-21 13:40:44 -0800733 !(oper->ht_param & HT_INFO_HT_PARAM_STA_CHNL_WIDTH) &&
734 sta->ht_capabilities) {
Paul Stewart092955c2017-02-06 09:13:09 -0800735 wpa_msg(wpa_s, MSG_DEBUG, MACSTR
736 " does not support 40 MHz bandwidth",
737 MAC2STR(sta->addr));
738 set_disable_ht40(sta->ht_capabilities, 1);
739 }
740
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800741 update_ht_state(data, sta);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800742
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800743#ifdef CONFIG_IEEE80211AC
744 copy_sta_vht_capab(data, sta, elems->vht_capabilities);
Hai Shalom74f70d42019-02-11 14:42:39 -0800745 copy_sta_vht_oper(data, sta, elems->vht_operation);
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800746 set_sta_vht_opmode(data, sta, elems->vht_opmode_notif);
747#endif /* CONFIG_IEEE80211AC */
748
Hai Shalom81f62d82019-07-22 12:10:00 -0700749#ifdef CONFIG_IEEE80211AX
750 copy_sta_he_capab(data, sta, IEEE80211_MODE_MESH,
751 elems->he_capabilities, elems->he_capabilities_len);
752#endif /* CONFIG_IEEE80211AX */
753
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800754 if (hostapd_get_aid(data, sta) < 0) {
755 wpa_msg(wpa_s, MSG_ERROR, "No AIDs available");
756 ap_free_sta(data, sta);
757 return NULL;
758 }
759
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800760 /* insert into driver */
761 os_memset(&params, 0, sizeof(params));
762 params.supp_rates = sta->supported_rates;
763 params.supp_rates_len = sta->supported_rates_len;
764 params.addr = addr;
765 params.plink_state = sta->plink_state;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800766 params.aid = sta->aid;
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700767 params.peer_aid = sta->peer_aid;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800768 params.listen_interval = 100;
769 params.ht_capabilities = sta->ht_capabilities;
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800770 params.vht_capabilities = sta->vht_capabilities;
Hai Shalom81f62d82019-07-22 12:10:00 -0700771 params.he_capab = sta->he_capab;
772 params.he_capab_len = sta->he_capab_len;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800773 params.flags |= WPA_STA_WMM;
774 params.flags_mask |= WPA_STA_AUTHENTICATED;
775 if (conf->security == MESH_CONF_SEC_NONE) {
776 params.flags |= WPA_STA_AUTHORIZED;
777 params.flags |= WPA_STA_AUTHENTICATED;
778 } else {
779 sta->flags |= WLAN_STA_MFP;
780 params.flags |= WPA_STA_MFP;
781 }
782
783 ret = wpa_drv_sta_add(wpa_s, &params);
784 if (ret) {
785 wpa_msg(wpa_s, MSG_ERROR,
786 "Driver failed to insert " MACSTR ": %d",
787 MAC2STR(addr), ret);
Dmitry Shmidt216983b2015-02-06 10:50:36 -0800788 ap_free_sta(data, sta);
789 return NULL;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800790 }
791
Dmitry Shmidt216983b2015-02-06 10:50:36 -0800792 return sta;
793}
794
795
796void wpa_mesh_new_mesh_peer(struct wpa_supplicant *wpa_s, const u8 *addr,
797 struct ieee802_11_elems *elems)
798{
799 struct mesh_conf *conf = wpa_s->ifmsh->mconf;
800 struct hostapd_data *data = wpa_s->ifmsh->bss[0];
801 struct sta_info *sta;
802 struct wpa_ssid *ssid = wpa_s->current_ssid;
803
804 sta = mesh_mpm_add_peer(wpa_s, addr, elems);
805 if (!sta)
806 return;
807
Dmitry Shmidte4663042016-04-04 10:07:49 -0700808 if (ssid && ssid->no_auto_peer &&
809 (is_zero_ether_addr(data->mesh_required_peer) ||
810 os_memcmp(data->mesh_required_peer, addr, ETH_ALEN) != 0)) {
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800811 wpa_msg(wpa_s, MSG_INFO, "will not initiate new peer link with "
812 MACSTR " because of no_auto_peer", MAC2STR(addr));
813 if (data->mesh_pending_auth) {
814 struct os_reltime age;
815 const struct ieee80211_mgmt *mgmt;
816 struct hostapd_frame_info fi;
817
818 mgmt = wpabuf_head(data->mesh_pending_auth);
819 os_reltime_age(&data->mesh_pending_auth_time, &age);
820 if (age.sec < 2 &&
821 os_memcmp(mgmt->sa, addr, ETH_ALEN) == 0) {
822 wpa_printf(MSG_DEBUG,
823 "mesh: Process pending Authentication frame from %u.%06u seconds ago",
824 (unsigned int) age.sec,
825 (unsigned int) age.usec);
826 os_memset(&fi, 0, sizeof(fi));
827 ieee802_11_mgmt(
828 data,
829 wpabuf_head(data->mesh_pending_auth),
830 wpabuf_len(data->mesh_pending_auth),
831 &fi);
832 }
833 wpabuf_free(data->mesh_pending_auth);
834 data->mesh_pending_auth = NULL;
835 }
836 return;
837 }
838
Dmitry Shmidtde47be72016-01-07 12:52:55 -0800839 if (conf->security == MESH_CONF_SEC_NONE) {
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700840 if (sta->plink_state < PLINK_OPN_SNT ||
Dmitry Shmidtde47be72016-01-07 12:52:55 -0800841 sta->plink_state > PLINK_ESTAB)
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700842 mesh_mpm_plink_open(wpa_s, sta, PLINK_OPN_SNT);
Dmitry Shmidtde47be72016-01-07 12:52:55 -0800843 } else {
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800844 mesh_rsn_auth_sae_sta(wpa_s, sta);
Dmitry Shmidtde47be72016-01-07 12:52:55 -0800845 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800846}
847
848
849void mesh_mpm_mgmt_rx(struct wpa_supplicant *wpa_s, struct rx_mgmt *rx_mgmt)
850{
851 struct hostapd_frame_info fi;
852
853 os_memset(&fi, 0, sizeof(fi));
854 fi.datarate = rx_mgmt->datarate;
855 fi.ssi_signal = rx_mgmt->ssi_signal;
856 ieee802_11_mgmt(wpa_s->ifmsh->bss[0], rx_mgmt->frame,
857 rx_mgmt->frame_len, &fi);
858}
859
860
861static void mesh_mpm_plink_estab(struct wpa_supplicant *wpa_s,
862 struct sta_info *sta)
863{
864 struct hostapd_data *hapd = wpa_s->ifmsh->bss[0];
865 struct mesh_conf *conf = wpa_s->ifmsh->mconf;
866 u8 seq[6] = {};
867
868 wpa_msg(wpa_s, MSG_INFO, "mesh plink with " MACSTR " established",
869 MAC2STR(sta->addr));
870
871 if (conf->security & MESH_CONF_SEC_AMPE) {
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700872 wpa_hexdump_key(MSG_DEBUG, "mesh: MTK", sta->mtk, sta->mtk_len);
873 wpa_drv_set_key(wpa_s, wpa_cipher_to_alg(conf->pairwise_cipher),
874 sta->addr, 0, 0, seq, sizeof(seq),
Hai Shalomfdcde762020-04-02 11:19:20 -0700875 sta->mtk, sta->mtk_len,
876 KEY_FLAG_PAIRWISE_RX_TX);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800877
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700878 wpa_hexdump_key(MSG_DEBUG, "mesh: RX MGTK Key RSC",
879 sta->mgtk_rsc, sizeof(sta->mgtk_rsc));
880 wpa_hexdump_key(MSG_DEBUG, "mesh: RX MGTK",
881 sta->mgtk, sta->mgtk_len);
882 wpa_drv_set_key(wpa_s, wpa_cipher_to_alg(conf->group_cipher),
883 sta->addr, sta->mgtk_key_id, 0,
884 sta->mgtk_rsc, sizeof(sta->mgtk_rsc),
Hai Shalomfdcde762020-04-02 11:19:20 -0700885 sta->mgtk, sta->mgtk_len,
886 KEY_FLAG_GROUP_RX);
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700887
888 if (sta->igtk_len) {
889 wpa_hexdump_key(MSG_DEBUG, "mesh: RX IGTK Key RSC",
890 sta->igtk_rsc, sizeof(sta->igtk_rsc));
891 wpa_hexdump_key(MSG_DEBUG, "mesh: RX IGTK",
892 sta->igtk, sta->igtk_len);
893 wpa_drv_set_key(
894 wpa_s,
895 wpa_cipher_to_alg(conf->mgmt_group_cipher),
896 sta->addr, sta->igtk_key_id, 0,
897 sta->igtk_rsc, sizeof(sta->igtk_rsc),
Hai Shalomfdcde762020-04-02 11:19:20 -0700898 sta->igtk, sta->igtk_len,
899 KEY_FLAG_GROUP_RX);
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700900 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800901 }
902
903 wpa_mesh_set_plink_state(wpa_s, sta, PLINK_ESTAB);
904 hapd->num_plinks++;
905
906 sta->flags |= WLAN_STA_ASSOC;
Dmitry Shmidte4663042016-04-04 10:07:49 -0700907 sta->mesh_sae_pmksa_caching = 0;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800908
Dmitry Shmidte4663042016-04-04 10:07:49 -0700909 eloop_cancel_timeout(peer_add_timer, wpa_s, NULL);
910 peer_add_timer(wpa_s, NULL);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800911 eloop_cancel_timeout(plink_timer, wpa_s, sta);
912
913 /* Send ctrl event */
Dmitry Shmidtde47be72016-01-07 12:52:55 -0800914 wpa_msg(wpa_s, MSG_INFO, MESH_PEER_CONNECTED MACSTR,
915 MAC2STR(sta->addr));
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700916
917 /* Send D-Bus event */
918 wpas_notify_mesh_peer_connected(wpa_s, sta->addr);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800919}
920
921
922static void mesh_mpm_fsm(struct wpa_supplicant *wpa_s, struct sta_info *sta,
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700923 enum plink_event event, u16 reason)
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800924{
925 struct hostapd_data *hapd = wpa_s->ifmsh->bss[0];
926 struct mesh_conf *conf = wpa_s->ifmsh->mconf;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800927
928 wpa_msg(wpa_s, MSG_DEBUG, "MPM " MACSTR " state %s event %s",
929 MAC2STR(sta->addr), mplstate[sta->plink_state],
930 mplevent[event]);
931
932 switch (sta->plink_state) {
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700933 case PLINK_IDLE:
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800934 switch (event) {
935 case CLS_ACPT:
936 mesh_mpm_fsm_restart(wpa_s, sta);
937 break;
938 case OPN_ACPT:
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700939 mesh_mpm_plink_open(wpa_s, sta, PLINK_OPN_RCVD);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800940 mesh_mpm_send_plink_action(wpa_s, sta, PLINK_CONFIRM,
941 0);
942 break;
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700943 case REQ_RJCT:
944 mesh_mpm_send_plink_action(wpa_s, sta,
945 PLINK_CLOSE, reason);
946 break;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800947 default:
948 break;
949 }
950 break;
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700951 case PLINK_OPN_SNT:
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800952 switch (event) {
953 case OPN_RJCT:
954 case CNF_RJCT:
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700955 if (!reason)
956 reason = WLAN_REASON_MESH_CONFIG_POLICY_VIOLATION;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800957 /* fall-through */
958 case CLS_ACPT:
959 wpa_mesh_set_plink_state(wpa_s, sta, PLINK_HOLDING);
960 if (!reason)
961 reason = WLAN_REASON_MESH_CLOSE_RCVD;
962 eloop_register_timeout(
963 conf->dot11MeshHoldingTimeout / 1000,
964 (conf->dot11MeshHoldingTimeout % 1000) * 1000,
965 plink_timer, wpa_s, sta);
966 mesh_mpm_send_plink_action(wpa_s, sta,
967 PLINK_CLOSE, reason);
968 break;
969 case OPN_ACPT:
970 /* retry timer is left untouched */
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700971 wpa_mesh_set_plink_state(wpa_s, sta, PLINK_OPN_RCVD);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800972 mesh_mpm_send_plink_action(wpa_s, sta,
973 PLINK_CONFIRM, 0);
974 break;
975 case CNF_ACPT:
976 wpa_mesh_set_plink_state(wpa_s, sta, PLINK_CNF_RCVD);
Dmitry Shmidt849734c2016-05-27 09:59:01 -0700977 eloop_cancel_timeout(plink_timer, wpa_s, sta);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800978 eloop_register_timeout(
979 conf->dot11MeshConfirmTimeout / 1000,
980 (conf->dot11MeshConfirmTimeout % 1000) * 1000,
981 plink_timer, wpa_s, sta);
982 break;
983 default:
984 break;
985 }
986 break;
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700987 case PLINK_OPN_RCVD:
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800988 switch (event) {
989 case OPN_RJCT:
990 case CNF_RJCT:
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -0700991 if (!reason)
992 reason = WLAN_REASON_MESH_CONFIG_POLICY_VIOLATION;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800993 /* fall-through */
994 case CLS_ACPT:
995 wpa_mesh_set_plink_state(wpa_s, sta, PLINK_HOLDING);
996 if (!reason)
997 reason = WLAN_REASON_MESH_CLOSE_RCVD;
998 eloop_register_timeout(
999 conf->dot11MeshHoldingTimeout / 1000,
1000 (conf->dot11MeshHoldingTimeout % 1000) * 1000,
1001 plink_timer, wpa_s, sta);
1002 sta->mpm_close_reason = reason;
1003 mesh_mpm_send_plink_action(wpa_s, sta,
1004 PLINK_CLOSE, reason);
1005 break;
1006 case OPN_ACPT:
1007 mesh_mpm_send_plink_action(wpa_s, sta,
1008 PLINK_CONFIRM, 0);
1009 break;
1010 case CNF_ACPT:
1011 if (conf->security & MESH_CONF_SEC_AMPE)
1012 mesh_rsn_derive_mtk(wpa_s, sta);
1013 mesh_mpm_plink_estab(wpa_s, sta);
1014 break;
1015 default:
1016 break;
1017 }
1018 break;
1019 case PLINK_CNF_RCVD:
1020 switch (event) {
1021 case OPN_RJCT:
1022 case CNF_RJCT:
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001023 if (!reason)
1024 reason = WLAN_REASON_MESH_CONFIG_POLICY_VIOLATION;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001025 /* fall-through */
1026 case CLS_ACPT:
1027 wpa_mesh_set_plink_state(wpa_s, sta, PLINK_HOLDING);
1028 if (!reason)
1029 reason = WLAN_REASON_MESH_CLOSE_RCVD;
1030 eloop_register_timeout(
1031 conf->dot11MeshHoldingTimeout / 1000,
1032 (conf->dot11MeshHoldingTimeout % 1000) * 1000,
1033 plink_timer, wpa_s, sta);
1034 sta->mpm_close_reason = reason;
1035 mesh_mpm_send_plink_action(wpa_s, sta,
1036 PLINK_CLOSE, reason);
1037 break;
1038 case OPN_ACPT:
Dmitry Shmidt849734c2016-05-27 09:59:01 -07001039 if (conf->security & MESH_CONF_SEC_AMPE)
1040 mesh_rsn_derive_mtk(wpa_s, sta);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001041 mesh_mpm_plink_estab(wpa_s, sta);
1042 mesh_mpm_send_plink_action(wpa_s, sta,
1043 PLINK_CONFIRM, 0);
1044 break;
1045 default:
1046 break;
1047 }
1048 break;
1049 case PLINK_ESTAB:
1050 switch (event) {
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001051 case OPN_RJCT:
1052 case CNF_RJCT:
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001053 case CLS_ACPT:
1054 wpa_mesh_set_plink_state(wpa_s, sta, PLINK_HOLDING);
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001055 if (!reason)
1056 reason = WLAN_REASON_MESH_CLOSE_RCVD;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001057
1058 eloop_register_timeout(
1059 conf->dot11MeshHoldingTimeout / 1000,
1060 (conf->dot11MeshHoldingTimeout % 1000) * 1000,
1061 plink_timer, wpa_s, sta);
1062 sta->mpm_close_reason = reason;
1063
1064 wpa_msg(wpa_s, MSG_INFO, "mesh plink with " MACSTR
1065 " closed with reason %d",
1066 MAC2STR(sta->addr), reason);
1067
Dmitry Shmidtde47be72016-01-07 12:52:55 -08001068 wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
1069 MAC2STR(sta->addr));
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001070
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001071 /* Send D-Bus event */
1072 wpas_notify_mesh_peer_disconnected(wpa_s, sta->addr,
1073 reason);
1074
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001075 hapd->num_plinks--;
1076
1077 mesh_mpm_send_plink_action(wpa_s, sta,
1078 PLINK_CLOSE, reason);
1079 break;
1080 case OPN_ACPT:
1081 mesh_mpm_send_plink_action(wpa_s, sta,
1082 PLINK_CONFIRM, 0);
1083 break;
1084 default:
1085 break;
1086 }
1087 break;
1088 case PLINK_HOLDING:
1089 switch (event) {
1090 case CLS_ACPT:
1091 mesh_mpm_fsm_restart(wpa_s, sta);
1092 break;
1093 case OPN_ACPT:
1094 case CNF_ACPT:
1095 case OPN_RJCT:
1096 case CNF_RJCT:
1097 reason = sta->mpm_close_reason;
1098 mesh_mpm_send_plink_action(wpa_s, sta,
1099 PLINK_CLOSE, reason);
1100 break;
1101 default:
1102 break;
1103 }
1104 break;
1105 default:
1106 wpa_msg(wpa_s, MSG_DEBUG,
1107 "Unsupported MPM event %s for state %s",
1108 mplevent[event], mplstate[sta->plink_state]);
1109 break;
1110 }
1111}
1112
1113
1114void mesh_mpm_action_rx(struct wpa_supplicant *wpa_s,
1115 const struct ieee80211_mgmt *mgmt, size_t len)
1116{
1117 u8 action_field;
1118 struct hostapd_data *hapd = wpa_s->ifmsh->bss[0];
1119 struct mesh_conf *mconf = wpa_s->ifmsh->mconf;
1120 struct sta_info *sta;
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001121 u16 plid = 0, llid = 0, aid = 0;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001122 enum plink_event event;
1123 struct ieee802_11_elems elems;
1124 struct mesh_peer_mgmt_ie peer_mgmt_ie;
1125 const u8 *ies;
1126 size_t ie_len;
1127 int ret;
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001128 u16 reason = 0;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001129
1130 if (mgmt->u.action.category != WLAN_ACTION_SELF_PROTECTED)
1131 return;
1132
1133 action_field = mgmt->u.action.u.slf_prot_action.action;
1134 if (action_field != PLINK_OPEN &&
1135 action_field != PLINK_CONFIRM &&
1136 action_field != PLINK_CLOSE)
1137 return;
1138
1139 ies = mgmt->u.action.u.slf_prot_action.variable;
1140 ie_len = (const u8 *) mgmt + len -
1141 mgmt->u.action.u.slf_prot_action.variable;
1142
1143 /* at least expect mesh id and peering mgmt */
1144 if (ie_len < 2 + 2) {
1145 wpa_printf(MSG_DEBUG,
1146 "MPM: Ignore too short action frame %u ie_len %u",
1147 action_field, (unsigned int) ie_len);
1148 return;
1149 }
1150 wpa_printf(MSG_DEBUG, "MPM: Received PLINK action %u", action_field);
1151
1152 if (action_field == PLINK_OPEN || action_field == PLINK_CONFIRM) {
1153 wpa_printf(MSG_DEBUG, "MPM: Capability 0x%x",
1154 WPA_GET_LE16(ies));
1155 ies += 2; /* capability */
1156 ie_len -= 2;
1157 }
1158 if (action_field == PLINK_CONFIRM) {
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001159 aid = WPA_GET_LE16(ies);
1160 wpa_printf(MSG_DEBUG, "MPM: AID 0x%x", aid);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001161 ies += 2; /* aid */
1162 ie_len -= 2;
1163 }
1164
1165 /* check for mesh peering, mesh id and mesh config IEs */
1166 if (ieee802_11_parse_elems(ies, ie_len, &elems, 0) == ParseFailed) {
1167 wpa_printf(MSG_DEBUG, "MPM: Failed to parse PLINK IEs");
1168 return;
1169 }
1170 if (!elems.peer_mgmt) {
1171 wpa_printf(MSG_DEBUG,
1172 "MPM: No Mesh Peering Management element");
1173 return;
1174 }
1175 if (action_field != PLINK_CLOSE) {
1176 if (!elems.mesh_id || !elems.mesh_config) {
1177 wpa_printf(MSG_DEBUG,
1178 "MPM: No Mesh ID or Mesh Configuration element");
1179 return;
1180 }
1181
1182 if (!matches_local(wpa_s, &elems)) {
1183 wpa_printf(MSG_DEBUG,
1184 "MPM: Mesh ID or Mesh Configuration element do not match local MBSS");
1185 return;
1186 }
1187 }
1188
1189 ret = mesh_mpm_parse_peer_mgmt(wpa_s, action_field,
1190 elems.peer_mgmt,
1191 elems.peer_mgmt_len,
1192 &peer_mgmt_ie);
1193 if (ret) {
1194 wpa_printf(MSG_DEBUG, "MPM: Mesh parsing rejected frame");
1195 return;
1196 }
1197
1198 /* the sender's llid is our plid and vice-versa */
1199 plid = WPA_GET_LE16(peer_mgmt_ie.llid);
1200 if (peer_mgmt_ie.plid)
1201 llid = WPA_GET_LE16(peer_mgmt_ie.plid);
1202 wpa_printf(MSG_DEBUG, "MPM: plid=0x%x llid=0x%x", plid, llid);
1203
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001204 if (action_field == PLINK_CLOSE)
1205 wpa_printf(MSG_DEBUG, "MPM: close reason=%u",
1206 WPA_GET_LE16(peer_mgmt_ie.reason));
1207
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001208 sta = ap_get_sta(hapd, mgmt->sa);
Dmitry Shmidt216983b2015-02-06 10:50:36 -08001209
1210 /*
1211 * If this is an open frame from an unknown STA, and this is an
1212 * open mesh, then go ahead and add the peer before proceeding.
1213 */
1214 if (!sta && action_field == PLINK_OPEN &&
Dmitry Shmidte4663042016-04-04 10:07:49 -07001215 (!(mconf->security & MESH_CONF_SEC_AMPE) ||
Dmitry Shmidt9839ecd2016-11-07 11:05:47 -08001216 wpa_auth_pmksa_get(hapd->wpa_auth, mgmt->sa, NULL)))
Dmitry Shmidt216983b2015-02-06 10:50:36 -08001217 sta = mesh_mpm_add_peer(wpa_s, mgmt->sa, &elems);
1218
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001219 if (!sta) {
1220 wpa_printf(MSG_DEBUG, "MPM: No STA entry for peer");
1221 return;
1222 }
1223
1224#ifdef CONFIG_SAE
1225 /* peer is in sae_accepted? */
1226 if (sta->sae && sta->sae->state != SAE_ACCEPTED) {
1227 wpa_printf(MSG_DEBUG, "MPM: SAE not yet accepted for peer");
1228 return;
1229 }
1230#endif /* CONFIG_SAE */
1231
1232 if (!sta->my_lid)
1233 mesh_mpm_init_link(wpa_s, sta);
1234
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001235 if (mconf->security & MESH_CONF_SEC_AMPE) {
1236 int res;
1237
1238 res = mesh_rsn_process_ampe(wpa_s, sta, &elems,
1239 &mgmt->u.action.category,
1240 peer_mgmt_ie.chosen_pmk,
1241 ies, ie_len);
1242 if (res) {
1243 wpa_printf(MSG_DEBUG,
1244 "MPM: RSN process rejected frame (res=%d)",
1245 res);
1246 if (action_field == PLINK_OPEN && res == -2) {
1247 /* AES-SIV decryption failed */
1248 mesh_mpm_fsm(wpa_s, sta, OPN_RJCT,
1249 WLAN_REASON_MESH_INVALID_GTK);
1250 }
1251 return;
1252 }
Hai Shalom74f70d42019-02-11 14:42:39 -08001253
1254#ifdef CONFIG_OCV
1255 if (action_field == PLINK_OPEN && elems.rsn_ie) {
1256 struct wpa_state_machine *sm = sta->wpa_sm;
1257 struct wpa_ie_data data;
1258
1259 res = wpa_parse_wpa_ie_rsn(elems.rsn_ie - 2,
1260 elems.rsn_ie_len + 2,
1261 &data);
1262 if (res) {
1263 wpa_printf(MSG_DEBUG,
1264 "Failed to parse RSN IE (res=%d)",
1265 res);
1266 wpa_hexdump(MSG_DEBUG, "RSN IE", elems.rsn_ie,
1267 elems.rsn_ie_len);
1268 return;
1269 }
1270
1271 wpa_auth_set_ocv(sm, mconf->ocv &&
1272 (data.capabilities &
1273 WPA_CAPABILITY_OCVC));
1274 }
1275
1276 if (action_field != PLINK_CLOSE &&
1277 wpa_auth_uses_ocv(sta->wpa_sm)) {
1278 struct wpa_channel_info ci;
1279 int tx_chanwidth;
1280 int tx_seg1_idx;
1281
1282 if (wpa_drv_channel_info(wpa_s, &ci) != 0) {
1283 wpa_printf(MSG_WARNING,
1284 "MPM: Failed to get channel info to validate received OCI in MPM Confirm");
1285 return;
1286 }
1287
1288 if (get_tx_parameters(
1289 sta, channel_width_to_int(ci.chanwidth),
1290 ci.seg1_idx, &tx_chanwidth,
1291 &tx_seg1_idx) < 0)
1292 return;
1293
1294 if (ocv_verify_tx_params(elems.oci, elems.oci_len, &ci,
1295 tx_chanwidth, tx_seg1_idx) !=
Hai Shalom899fcc72020-10-19 14:38:18 -07001296 OCI_SUCCESS) {
1297 wpa_printf(MSG_WARNING, "MPM: OCV failed: %s",
Hai Shalom74f70d42019-02-11 14:42:39 -08001298 ocv_errorstr);
1299 return;
1300 }
1301 }
1302#endif /* CONFIG_OCV */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001303 }
1304
1305 if (sta->plink_state == PLINK_BLOCKED) {
1306 wpa_printf(MSG_DEBUG, "MPM: PLINK_BLOCKED");
1307 return;
1308 }
1309
1310 /* Now we will figure out the appropriate event... */
1311 switch (action_field) {
1312 case PLINK_OPEN:
1313 if (plink_free_count(hapd) == 0) {
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001314 event = REQ_RJCT;
1315 reason = WLAN_REASON_MESH_MAX_PEERS;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001316 wpa_printf(MSG_INFO,
1317 "MPM: Peer link num over quota(%d)",
1318 hapd->max_plinks);
1319 } else if (sta->peer_lid && sta->peer_lid != plid) {
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001320 wpa_printf(MSG_DEBUG,
1321 "MPM: peer_lid mismatch: 0x%x != 0x%x",
1322 sta->peer_lid, plid);
1323 return; /* no FSM event */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001324 } else {
1325 sta->peer_lid = plid;
1326 event = OPN_ACPT;
1327 }
1328 break;
1329 case PLINK_CONFIRM:
1330 if (plink_free_count(hapd) == 0) {
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001331 event = REQ_RJCT;
1332 reason = WLAN_REASON_MESH_MAX_PEERS;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001333 wpa_printf(MSG_INFO,
1334 "MPM: Peer link num over quota(%d)",
1335 hapd->max_plinks);
1336 } else if (sta->my_lid != llid ||
1337 (sta->peer_lid && sta->peer_lid != plid)) {
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001338 wpa_printf(MSG_DEBUG,
1339 "MPM: lid mismatch: my_lid: 0x%x != 0x%x or peer_lid: 0x%x != 0x%x",
1340 sta->my_lid, llid, sta->peer_lid, plid);
1341 return; /* no FSM event */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001342 } else {
1343 if (!sta->peer_lid)
1344 sta->peer_lid = plid;
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001345 sta->peer_aid = aid;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001346 event = CNF_ACPT;
1347 }
1348 break;
1349 case PLINK_CLOSE:
1350 if (sta->plink_state == PLINK_ESTAB)
1351 /* Do not check for llid or plid. This does not
1352 * follow the standard but since multiple plinks
1353 * per cand are not supported, it is necessary in
1354 * order to avoid a livelock when MP A sees an
1355 * establish peer link to MP B but MP B does not
1356 * see it. This can be caused by a timeout in
1357 * B's peer link establishment or B being
1358 * restarted.
1359 */
1360 event = CLS_ACPT;
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001361 else if (sta->peer_lid != plid) {
1362 wpa_printf(MSG_DEBUG,
1363 "MPM: peer_lid mismatch: 0x%x != 0x%x",
1364 sta->peer_lid, plid);
1365 return; /* no FSM event */
1366 } else if (peer_mgmt_ie.plid && sta->my_lid != llid) {
1367 wpa_printf(MSG_DEBUG,
1368 "MPM: my_lid mismatch: 0x%x != 0x%x",
1369 sta->my_lid, llid);
1370 return; /* no FSM event */
1371 } else {
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001372 event = CLS_ACPT;
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001373 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001374 break;
1375 default:
1376 /*
1377 * This cannot be hit due to the action_field check above, but
1378 * compilers may not be able to figure that out and can warn
1379 * about uninitialized event below.
1380 */
1381 return;
1382 }
Dmitry Shmidt58d12ad2016-07-28 10:07:03 -07001383 mesh_mpm_fsm(wpa_s, sta, event, reason);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001384}
1385
1386
1387/* called by ap_free_sta */
Dmitry Shmidtb97e4282016-02-08 10:16:07 -08001388void mesh_mpm_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001389{
Dmitry Shmidtb97e4282016-02-08 10:16:07 -08001390 if (sta->plink_state == PLINK_ESTAB)
1391 hapd->num_plinks--;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001392 eloop_cancel_timeout(plink_timer, ELOOP_ALL_CTX, sta);
1393 eloop_cancel_timeout(mesh_auth_timer, ELOOP_ALL_CTX, sta);
1394}