blob: c384154ac89506d3b153792c1440909d9abb78ca [file] [log] [blame]
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +01001/*
Rui Paulo264d9b72009-11-09 23:46:58 +00002 * Copyright (c) 2008, 2009 open80211s Ltd.
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +01003 * Author: Luis Carlos Cobo <luisca@cozybit.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
Johannes Berg902acc72008-02-23 15:17:19 +01009#include <linux/kernel.h>
10#include <linux/random.h>
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010011#include "ieee80211_i.h"
Johannes Berg2c8dccc2008-04-08 15:14:40 -040012#include "rate.h"
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010013#include "mesh.h"
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010014
15#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
16#define mpl_dbg(fmt, args...) printk(KERN_DEBUG fmt, ##args)
17#else
18#define mpl_dbg(fmt, args...) do { (void)(0); } while (0)
19#endif
20
Rui Paulo09383932009-11-09 23:46:43 +000021#define PLINK_GET_LLID(p) (p + 4)
22#define PLINK_GET_PLID(p) (p + 6)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010023
24#define mod_plink_timer(s, t) (mod_timer(&s->plink_timer, \
25 jiffies + HZ * t / 1000))
26
27/* Peer link cancel reasons, all subject to ANA approval */
28#define MESH_LINK_CANCELLED 2
29#define MESH_MAX_NEIGHBORS 3
30#define MESH_CAPABILITY_POLICY_VIOLATION 4
31#define MESH_CLOSE_RCVD 5
32#define MESH_MAX_RETRIES 6
33#define MESH_CONFIRM_TIMEOUT 7
34#define MESH_SECURITY_ROLE_NEGOTIATION_DIFFERS 8
35#define MESH_SECURITY_AUTHENTICATION_IMPOSSIBLE 9
36#define MESH_SECURITY_FAILED_VERIFICATION 10
37
Johannes Berg472dbc42008-09-11 00:01:49 +020038#define dot11MeshMaxRetries(s) (s->u.mesh.mshcfg.dot11MeshMaxRetries)
39#define dot11MeshRetryTimeout(s) (s->u.mesh.mshcfg.dot11MeshRetryTimeout)
40#define dot11MeshConfirmTimeout(s) (s->u.mesh.mshcfg.dot11MeshConfirmTimeout)
41#define dot11MeshHoldingTimeout(s) (s->u.mesh.mshcfg.dot11MeshHoldingTimeout)
42#define dot11MeshMaxPeerLinks(s) (s->u.mesh.mshcfg.dot11MeshMaxPeerLinks)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010043
44enum plink_frame_type {
45 PLINK_OPEN = 0,
46 PLINK_CONFIRM,
47 PLINK_CLOSE
48};
49
50enum plink_event {
51 PLINK_UNDEFINED,
52 OPN_ACPT,
53 OPN_RJCT,
54 OPN_IGNR,
55 CNF_ACPT,
56 CNF_RJCT,
57 CNF_IGNR,
58 CLS_ACPT,
59 CLS_IGNR
60};
61
62static inline
63void mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata)
64{
Johannes Berg472dbc42008-09-11 00:01:49 +020065 atomic_inc(&sdata->u.mesh.mshstats.estab_plinks);
Johannes Bergd0709a62008-02-25 16:27:46 +010066 mesh_accept_plinks_update(sdata);
Rui Paulo8f2fda92009-11-09 23:46:41 +000067 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010068}
69
70static inline
71void mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata)
72{
Johannes Berg472dbc42008-09-11 00:01:49 +020073 atomic_dec(&sdata->u.mesh.mshstats.estab_plinks);
Johannes Bergd0709a62008-02-25 16:27:46 +010074 mesh_accept_plinks_update(sdata);
Rui Paulo8f2fda92009-11-09 23:46:41 +000075 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010076}
77
78/**
79 * mesh_plink_fsm_restart - restart a mesh peer link finite state machine
80 *
Rui Paulo23c7a292009-11-09 23:46:42 +000081 * @sta: mesh peer link to restart
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010082 *
Johannes Berg07346f812008-05-03 01:02:02 +020083 * Locking: this function must be called holding sta->lock
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010084 */
85static inline void mesh_plink_fsm_restart(struct sta_info *sta)
86{
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -080087 sta->plink_state = PLINK_LISTEN;
Luis Carlos Cobo37659ff2008-02-29 12:13:38 -080088 sta->llid = sta->plid = sta->reason = 0;
89 sta->plink_retries = 0;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010090}
91
Johannes Berg93e5deb2008-04-01 15:21:00 +020092/*
93 * NOTE: This is just an alias for sta_info_alloc(), see notes
94 * on it in the lifecycle management section!
95 */
Johannes Berg03e44972008-02-27 09:56:40 +010096static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
Johannes Berg881d9482009-01-21 15:13:48 +010097 u8 *hw_addr, u32 rates)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010098{
Johannes Bergd0709a62008-02-25 16:27:46 +010099 struct ieee80211_local *local = sdata->local;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100100 struct sta_info *sta;
101
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100102 if (local->num_sta >= MESH_MAX_PLINKS)
Johannes Berg73651ee2008-02-25 16:27:47 +0100103 return NULL;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100104
Johannes Berg34e89502010-02-03 13:59:58 +0100105 sta = sta_info_alloc(sdata, hw_addr, GFP_KERNEL);
Johannes Berg73651ee2008-02-25 16:27:47 +0100106 if (!sta)
107 return NULL;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100108
Johannes Berg07346f812008-05-03 01:02:02 +0200109 sta->flags = WLAN_STA_AUTHORIZED;
Johannes Berg323ce792008-09-11 02:45:11 +0200110 sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
Christian Lamparterb973c312008-12-27 22:19:49 +0100111 rate_control_rate_init(sta);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100112
113 return sta;
114}
115
116/**
Johannes Berg42096b62008-02-25 21:36:27 +0100117 * mesh_plink_deactivate - deactivate mesh peer link
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100118 *
119 * @sta: mesh peer link to deactivate
120 *
121 * All mesh paths with this peer as next hop will be flushed
122 *
Johannes Berg07346f812008-05-03 01:02:02 +0200123 * Locking: the caller must hold sta->lock
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100124 */
Johannes Berg902acc72008-02-23 15:17:19 +0100125static void __mesh_plink_deactivate(struct sta_info *sta)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100126{
Johannes Bergd0709a62008-02-25 16:27:46 +0100127 struct ieee80211_sub_if_data *sdata = sta->sdata;
128
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800129 if (sta->plink_state == PLINK_ESTAB)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100130 mesh_plink_dec_estab_count(sdata);
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800131 sta->plink_state = PLINK_BLOCKED;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100132 mesh_path_flush_by_nexthop(sta);
133}
134
Johannes Berg902acc72008-02-23 15:17:19 +0100135/**
136 * __mesh_plink_deactivate - deactivate mesh peer link
137 *
138 * @sta: mesh peer link to deactivate
139 *
140 * All mesh paths with this peer as next hop will be flushed
141 */
142void mesh_plink_deactivate(struct sta_info *sta)
143{
Johannes Berg07346f812008-05-03 01:02:02 +0200144 spin_lock_bh(&sta->lock);
Johannes Berg902acc72008-02-23 15:17:19 +0100145 __mesh_plink_deactivate(sta);
Johannes Berg07346f812008-05-03 01:02:02 +0200146 spin_unlock_bh(&sta->lock);
Johannes Berg902acc72008-02-23 15:17:19 +0100147}
148
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200149static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100150 enum plink_frame_type action, u8 *da, __le16 llid, __le16 plid,
151 __le16 reason) {
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200152 struct ieee80211_local *local = sdata->local;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100153 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
154 struct ieee80211_mgmt *mgmt;
155 bool include_plid = false;
Rui Paulo09383932009-11-09 23:46:43 +0000156 static const u8 meshpeeringproto[] = { 0x00, 0x0F, 0xAC, 0x2A };
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100157 u8 *pos;
158 int ie_len;
159
160 if (!skb)
161 return -1;
162 skb_reserve(skb, local->hw.extra_tx_headroom);
163 /* 25 is the size of the common mgmt part (24) plus the size of the
164 * common action part (1)
165 */
166 mgmt = (struct ieee80211_mgmt *)
167 skb_put(skb, 25 + sizeof(mgmt->u.action.u.plink_action));
168 memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.plink_action));
Harvey Harrisone7827a72008-07-15 18:44:13 -0700169 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
170 IEEE80211_STYPE_ACTION);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100171 memcpy(mgmt->da, da, ETH_ALEN);
Johannes Berg47846c92009-11-25 17:46:19 +0100172 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100173 /* BSSID is left zeroed, wildcard value */
Javier Cardona97ad9132010-03-29 11:00:21 -0700174 mgmt->u.action.category = WLAN_CATEGORY_MESH_PLINK;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100175 mgmt->u.action.u.plink_action.action_code = action;
176
177 if (action == PLINK_CLOSE)
178 mgmt->u.action.u.plink_action.aux = reason;
179 else {
180 mgmt->u.action.u.plink_action.aux = cpu_to_le16(0x0);
181 if (action == PLINK_CONFIRM) {
182 pos = skb_put(skb, 4);
183 /* two-byte status code followed by two-byte AID */
Rui Paulo77fa76b2009-11-09 23:46:52 +0000184 memset(pos, 0, 2);
185 memcpy(pos + 2, &plid, 2);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100186 }
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200187 mesh_mgmt_ies_add(skb, sdata);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100188 }
189
190 /* Add Peer Link Management element */
191 switch (action) {
192 case PLINK_OPEN:
Rui Paulo09383932009-11-09 23:46:43 +0000193 ie_len = 6;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100194 break;
195 case PLINK_CONFIRM:
Rui Paulo09383932009-11-09 23:46:43 +0000196 ie_len = 8;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100197 include_plid = true;
198 break;
199 case PLINK_CLOSE:
200 default:
201 if (!plid)
Rui Paulo09383932009-11-09 23:46:43 +0000202 ie_len = 8;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100203 else {
Rui Paulo09383932009-11-09 23:46:43 +0000204 ie_len = 10;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100205 include_plid = true;
206 }
207 break;
208 }
209
210 pos = skb_put(skb, 2 + ie_len);
211 *pos++ = WLAN_EID_PEER_LINK;
212 *pos++ = ie_len;
Rui Paulo09383932009-11-09 23:46:43 +0000213 memcpy(pos, meshpeeringproto, sizeof(meshpeeringproto));
214 pos += 4;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100215 memcpy(pos, &llid, 2);
216 if (include_plid) {
217 pos += 2;
218 memcpy(pos, &plid, 2);
219 }
220 if (action == PLINK_CLOSE) {
221 pos += 2;
222 memcpy(pos, &reason, 2);
223 }
224
Johannes Berg62ae67b2009-11-18 18:42:05 +0100225 ieee80211_tx_skb(sdata, skb);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100226 return 0;
227}
228
Johannes Berg881d9482009-01-21 15:13:48 +0100229void mesh_neighbour_update(u8 *hw_addr, u32 rates, struct ieee80211_sub_if_data *sdata,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100230 bool peer_accepting_plinks)
231{
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200232 struct ieee80211_local *local = sdata->local;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100233 struct sta_info *sta;
234
Johannes Bergd0709a62008-02-25 16:27:46 +0100235 rcu_read_lock();
236
Johannes Bergabe60632009-11-25 17:46:18 +0100237 sta = sta_info_get(sdata, hw_addr);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100238 if (!sta) {
Johannes Berg34e89502010-02-03 13:59:58 +0100239 rcu_read_unlock();
240
Johannes Berg03e44972008-02-27 09:56:40 +0100241 sta = mesh_plink_alloc(sdata, hw_addr, rates);
Johannes Berg34e89502010-02-03 13:59:58 +0100242 if (!sta)
Johannes Berg73651ee2008-02-25 16:27:47 +0100243 return;
Johannes Berg34e89502010-02-03 13:59:58 +0100244 if (sta_info_insert_rcu(sta)) {
Johannes Bergd0709a62008-02-25 16:27:46 +0100245 rcu_read_unlock();
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100246 return;
Johannes Bergd0709a62008-02-25 16:27:46 +0100247 }
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100248 }
249
250 sta->last_rx = jiffies;
Johannes Berg323ce792008-09-11 02:45:11 +0200251 sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800252 if (peer_accepting_plinks && sta->plink_state == PLINK_LISTEN &&
Johannes Berg472dbc42008-09-11 00:01:49 +0200253 sdata->u.mesh.accepting_plinks &&
254 sdata->u.mesh.mshcfg.auto_open_plinks)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100255 mesh_plink_open(sta);
256
Johannes Bergd0709a62008-02-25 16:27:46 +0100257 rcu_read_unlock();
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100258}
259
260static void mesh_plink_timer(unsigned long data)
261{
262 struct sta_info *sta;
263 __le16 llid, plid, reason;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100264 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100265
Johannes Bergd0709a62008-02-25 16:27:46 +0100266 /*
267 * This STA is valid because sta_info_destroy() will
268 * del_timer_sync() this timer after having made sure
269 * it cannot be readded (by deleting the plink.)
270 */
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100271 sta = (struct sta_info *) data;
272
Johannes Berg5bb644a2009-05-17 11:40:42 +0200273 if (sta->sdata->local->quiescing) {
274 sta->plink_timer_was_running = true;
275 return;
276 }
277
Johannes Berg07346f812008-05-03 01:02:02 +0200278 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100279 if (sta->ignore_plink_timer) {
280 sta->ignore_plink_timer = false;
Johannes Berg07346f812008-05-03 01:02:02 +0200281 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100282 return;
283 }
Johannes Berg0c68ae262008-10-27 15:56:10 -0700284 mpl_dbg("Mesh plink timer for %pM fired on state %d\n",
285 sta->sta.addr, sta->plink_state);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100286 reason = 0;
287 llid = sta->llid;
288 plid = sta->plid;
Johannes Bergd0709a62008-02-25 16:27:46 +0100289 sdata = sta->sdata;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100290
291 switch (sta->plink_state) {
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800292 case PLINK_OPN_RCVD:
293 case PLINK_OPN_SNT:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100294 /* retry timer */
295 if (sta->plink_retries < dot11MeshMaxRetries(sdata)) {
296 u32 rand;
Johannes Berg0c68ae262008-10-27 15:56:10 -0700297 mpl_dbg("Mesh plink for %pM (retry, timeout): %d %d\n",
298 sta->sta.addr, sta->plink_retries,
299 sta->plink_timeout);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100300 get_random_bytes(&rand, sizeof(u32));
301 sta->plink_timeout = sta->plink_timeout +
302 rand % sta->plink_timeout;
303 ++sta->plink_retries;
Johannes Bergd0709a62008-02-25 16:27:46 +0100304 mod_plink_timer(sta, sta->plink_timeout);
Johannes Berg07346f812008-05-03 01:02:02 +0200305 spin_unlock_bh(&sta->lock);
Johannes Berg17741cd2008-09-11 00:02:02 +0200306 mesh_plink_frame_tx(sdata, PLINK_OPEN, sta->sta.addr, llid,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100307 0, 0);
308 break;
309 }
310 reason = cpu_to_le16(MESH_MAX_RETRIES);
311 /* fall through on else */
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800312 case PLINK_CNF_RCVD:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100313 /* confirm timer */
314 if (!reason)
315 reason = cpu_to_le16(MESH_CONFIRM_TIMEOUT);
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800316 sta->plink_state = PLINK_HOLDING;
Johannes Bergd0709a62008-02-25 16:27:46 +0100317 mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata));
Johannes Berg07346f812008-05-03 01:02:02 +0200318 spin_unlock_bh(&sta->lock);
Johannes Berg17741cd2008-09-11 00:02:02 +0200319 mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr, llid, plid,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100320 reason);
321 break;
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800322 case PLINK_HOLDING:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100323 /* holding timer */
Johannes Bergd0709a62008-02-25 16:27:46 +0100324 del_timer(&sta->plink_timer);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100325 mesh_plink_fsm_restart(sta);
Johannes Berg07346f812008-05-03 01:02:02 +0200326 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100327 break;
328 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200329 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100330 break;
331 }
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100332}
333
Johannes Berg5bb644a2009-05-17 11:40:42 +0200334#ifdef CONFIG_PM
335void mesh_plink_quiesce(struct sta_info *sta)
336{
337 if (del_timer_sync(&sta->plink_timer))
338 sta->plink_timer_was_running = true;
339}
340
341void mesh_plink_restart(struct sta_info *sta)
342{
343 if (sta->plink_timer_was_running) {
344 add_timer(&sta->plink_timer);
345 sta->plink_timer_was_running = false;
346 }
347}
348#endif
349
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100350static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout)
351{
352 sta->plink_timer.expires = jiffies + (HZ * timeout / 1000);
353 sta->plink_timer.data = (unsigned long) sta;
354 sta->plink_timer.function = mesh_plink_timer;
355 sta->plink_timeout = timeout;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100356 add_timer(&sta->plink_timer);
357}
358
359int mesh_plink_open(struct sta_info *sta)
360{
361 __le16 llid;
Johannes Bergd0709a62008-02-25 16:27:46 +0100362 struct ieee80211_sub_if_data *sdata = sta->sdata;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100363
Johannes Berg07346f812008-05-03 01:02:02 +0200364 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100365 get_random_bytes(&llid, 2);
366 sta->llid = llid;
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800367 if (sta->plink_state != PLINK_LISTEN) {
Johannes Berg07346f812008-05-03 01:02:02 +0200368 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100369 return -EBUSY;
370 }
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800371 sta->plink_state = PLINK_OPN_SNT;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100372 mesh_plink_timer_set(sta, dot11MeshRetryTimeout(sdata));
Johannes Berg07346f812008-05-03 01:02:02 +0200373 spin_unlock_bh(&sta->lock);
Johannes Berg0c68ae262008-10-27 15:56:10 -0700374 mpl_dbg("Mesh plink: starting establishment with %pM\n",
375 sta->sta.addr);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100376
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200377 return mesh_plink_frame_tx(sdata, PLINK_OPEN,
Johannes Berg17741cd2008-09-11 00:02:02 +0200378 sta->sta.addr, llid, 0, 0);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100379}
380
381void mesh_plink_block(struct sta_info *sta)
382{
Johannes Berg07346f812008-05-03 01:02:02 +0200383 spin_lock_bh(&sta->lock);
Johannes Berg902acc72008-02-23 15:17:19 +0100384 __mesh_plink_deactivate(sta);
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800385 sta->plink_state = PLINK_BLOCKED;
Johannes Berg07346f812008-05-03 01:02:02 +0200386 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100387}
388
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100389
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200390void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100391 size_t len, struct ieee80211_rx_status *rx_status)
392{
Johannes Bergd0709a62008-02-25 16:27:46 +0100393 struct ieee80211_local *local = sdata->local;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100394 struct ieee802_11_elems elems;
395 struct sta_info *sta;
396 enum plink_event event;
397 enum plink_frame_type ftype;
398 size_t baselen;
399 u8 ie_len;
400 u8 *baseaddr;
401 __le16 plid, llid, reason;
Rui Paulo1460dd12009-11-09 23:46:48 +0000402#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
403 static const char *mplstates[] = {
404 [PLINK_LISTEN] = "LISTEN",
405 [PLINK_OPN_SNT] = "OPN-SNT",
406 [PLINK_OPN_RCVD] = "OPN-RCVD",
407 [PLINK_CNF_RCVD] = "CNF_RCVD",
408 [PLINK_ESTAB] = "ESTAB",
409 [PLINK_HOLDING] = "HOLDING",
410 [PLINK_BLOCKED] = "BLOCKED"
411 };
412#endif
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100413
Johannes Berg9c80d3d2008-09-08 15:41:59 +0200414 /* need action_code, aux */
415 if (len < IEEE80211_MIN_ACTION_SIZE + 3)
416 return;
417
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100418 if (is_multicast_ether_addr(mgmt->da)) {
419 mpl_dbg("Mesh plink: ignore frame from multicast address");
420 return;
421 }
422
423 baseaddr = mgmt->u.action.u.plink_action.variable;
424 baselen = (u8 *) mgmt->u.action.u.plink_action.variable - (u8 *) mgmt;
425 if (mgmt->u.action.u.plink_action.action_code == PLINK_CONFIRM) {
426 baseaddr += 4;
David Woo70bdb6b2009-08-12 11:03:44 -0700427 baselen += 4;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100428 }
429 ieee802_11_parse_elems(baseaddr, len - baselen, &elems);
430 if (!elems.peer_link) {
431 mpl_dbg("Mesh plink: missing necessary peer link ie\n");
432 return;
433 }
434
Rui Paulo09383932009-11-09 23:46:43 +0000435 ftype = mgmt->u.action.u.plink_action.action_code;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100436 ie_len = elems.peer_link_len;
Rui Paulo09383932009-11-09 23:46:43 +0000437 if ((ftype == PLINK_OPEN && ie_len != 6) ||
438 (ftype == PLINK_CONFIRM && ie_len != 8) ||
439 (ftype == PLINK_CLOSE && ie_len != 8 && ie_len != 10)) {
440 mpl_dbg("Mesh plink: incorrect plink ie length %d %d\n",
441 ftype, ie_len);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100442 return;
443 }
444
445 if (ftype != PLINK_CLOSE && (!elems.mesh_id || !elems.mesh_config)) {
446 mpl_dbg("Mesh plink: missing necessary ie\n");
447 return;
448 }
449 /* Note the lines below are correct, the llid in the frame is the plid
450 * from the point of view of this host.
451 */
452 memcpy(&plid, PLINK_GET_LLID(elems.peer_link), 2);
Rui Paulo09383932009-11-09 23:46:43 +0000453 if (ftype == PLINK_CONFIRM || (ftype == PLINK_CLOSE && ie_len == 10))
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100454 memcpy(&llid, PLINK_GET_PLID(elems.peer_link), 2);
455
Johannes Bergd0709a62008-02-25 16:27:46 +0100456 rcu_read_lock();
457
Johannes Bergabe60632009-11-25 17:46:18 +0100458 sta = sta_info_get(sdata, mgmt->sa);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100459 if (!sta && ftype != PLINK_OPEN) {
460 mpl_dbg("Mesh plink: cls or cnf from unknown peer\n");
Johannes Bergd0709a62008-02-25 16:27:46 +0100461 rcu_read_unlock();
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100462 return;
463 }
464
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800465 if (sta && sta->plink_state == PLINK_BLOCKED) {
Johannes Bergd0709a62008-02-25 16:27:46 +0100466 rcu_read_unlock();
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100467 return;
468 }
469
470 /* Now we will figure out the appropriate event... */
471 event = PLINK_UNDEFINED;
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200472 if (ftype != PLINK_CLOSE && (!mesh_matches_local(&elems, sdata))) {
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100473 switch (ftype) {
474 case PLINK_OPEN:
475 event = OPN_RJCT;
476 break;
477 case PLINK_CONFIRM:
478 event = CNF_RJCT;
479 break;
480 case PLINK_CLOSE:
481 /* avoid warning */
482 break;
483 }
Johannes Berg07346f812008-05-03 01:02:02 +0200484 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100485 } else if (!sta) {
486 /* ftype == PLINK_OPEN */
Johannes Berg881d9482009-01-21 15:13:48 +0100487 u32 rates;
Johannes Berg34e89502010-02-03 13:59:58 +0100488
489 rcu_read_unlock();
490
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100491 if (!mesh_plink_free_count(sdata)) {
492 mpl_dbg("Mesh plink error: no more free plinks\n");
493 return;
494 }
495
496 rates = ieee80211_sta_get_rates(local, &elems, rx_status->band);
Johannes Berg03e44972008-02-27 09:56:40 +0100497 sta = mesh_plink_alloc(sdata, mgmt->sa, rates);
Johannes Berg73651ee2008-02-25 16:27:47 +0100498 if (!sta) {
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100499 mpl_dbg("Mesh plink error: plink table full\n");
500 return;
501 }
Johannes Berg34e89502010-02-03 13:59:58 +0100502 if (sta_info_insert_rcu(sta)) {
Johannes Berg73651ee2008-02-25 16:27:47 +0100503 rcu_read_unlock();
504 return;
505 }
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100506 event = OPN_ACPT;
Johannes Berg07346f812008-05-03 01:02:02 +0200507 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100508 } else {
Johannes Berg07346f812008-05-03 01:02:02 +0200509 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100510 switch (ftype) {
511 case PLINK_OPEN:
512 if (!mesh_plink_free_count(sdata) ||
Johannes Bergd0709a62008-02-25 16:27:46 +0100513 (sta->plid && sta->plid != plid))
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100514 event = OPN_IGNR;
515 else
516 event = OPN_ACPT;
517 break;
518 case PLINK_CONFIRM:
519 if (!mesh_plink_free_count(sdata) ||
Johannes Bergd0709a62008-02-25 16:27:46 +0100520 (sta->llid != llid || sta->plid != plid))
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100521 event = CNF_IGNR;
522 else
523 event = CNF_ACPT;
524 break;
525 case PLINK_CLOSE:
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800526 if (sta->plink_state == PLINK_ESTAB)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100527 /* Do not check for llid or plid. This does not
528 * follow the standard but since multiple plinks
529 * per sta are not supported, it is necessary in
530 * order to avoid a livelock when MP A sees an
531 * establish peer link to MP B but MP B does not
532 * see it. This can be caused by a timeout in
533 * B's peer link establishment or B beign
534 * restarted.
535 */
536 event = CLS_ACPT;
537 else if (sta->plid != plid)
538 event = CLS_IGNR;
539 else if (ie_len == 7 && sta->llid != llid)
540 event = CLS_IGNR;
541 else
542 event = CLS_ACPT;
543 break;
544 default:
545 mpl_dbg("Mesh plink: unknown frame subtype\n");
Johannes Berg07346f812008-05-03 01:02:02 +0200546 spin_unlock_bh(&sta->lock);
Johannes Bergd0709a62008-02-25 16:27:46 +0100547 rcu_read_unlock();
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100548 return;
549 }
550 }
551
Rui Paulo1460dd12009-11-09 23:46:48 +0000552 mpl_dbg("Mesh plink (peer, state, llid, plid, event): %pM %s %d %d %d\n",
553 mgmt->sa, mplstates[sta->plink_state],
Johannes Berg0c68ae262008-10-27 15:56:10 -0700554 le16_to_cpu(sta->llid), le16_to_cpu(sta->plid),
555 event);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100556 reason = 0;
557 switch (sta->plink_state) {
558 /* spin_unlock as soon as state is updated at each case */
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800559 case PLINK_LISTEN:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100560 switch (event) {
561 case CLS_ACPT:
562 mesh_plink_fsm_restart(sta);
Johannes Berg07346f812008-05-03 01:02:02 +0200563 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100564 break;
565 case OPN_ACPT:
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800566 sta->plink_state = PLINK_OPN_RCVD;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100567 sta->plid = plid;
568 get_random_bytes(&llid, 2);
569 sta->llid = llid;
570 mesh_plink_timer_set(sta, dot11MeshRetryTimeout(sdata));
Johannes Berg07346f812008-05-03 01:02:02 +0200571 spin_unlock_bh(&sta->lock);
Johannes Berg17741cd2008-09-11 00:02:02 +0200572 mesh_plink_frame_tx(sdata, PLINK_OPEN, sta->sta.addr, llid,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100573 0, 0);
Johannes Berg17741cd2008-09-11 00:02:02 +0200574 mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100575 llid, plid, 0);
576 break;
577 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200578 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100579 break;
580 }
581 break;
582
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800583 case PLINK_OPN_SNT:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100584 switch (event) {
585 case OPN_RJCT:
586 case CNF_RJCT:
587 reason = cpu_to_le16(MESH_CAPABILITY_POLICY_VIOLATION);
588 case CLS_ACPT:
589 if (!reason)
590 reason = cpu_to_le16(MESH_CLOSE_RCVD);
591 sta->reason = reason;
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800592 sta->plink_state = PLINK_HOLDING;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100593 if (!mod_plink_timer(sta,
594 dot11MeshHoldingTimeout(sdata)))
595 sta->ignore_plink_timer = true;
596
597 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200598 spin_unlock_bh(&sta->lock);
Johannes Berg17741cd2008-09-11 00:02:02 +0200599 mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr, llid,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100600 plid, reason);
601 break;
602 case OPN_ACPT:
603 /* retry timer is left untouched */
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800604 sta->plink_state = PLINK_OPN_RCVD;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100605 sta->plid = plid;
606 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200607 spin_unlock_bh(&sta->lock);
Johannes Berg17741cd2008-09-11 00:02:02 +0200608 mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr, llid,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100609 plid, 0);
610 break;
611 case CNF_ACPT:
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800612 sta->plink_state = PLINK_CNF_RCVD;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100613 if (!mod_plink_timer(sta,
614 dot11MeshConfirmTimeout(sdata)))
615 sta->ignore_plink_timer = true;
616
Johannes Berg07346f812008-05-03 01:02:02 +0200617 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100618 break;
619 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200620 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100621 break;
622 }
623 break;
624
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800625 case PLINK_OPN_RCVD:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100626 switch (event) {
627 case OPN_RJCT:
628 case CNF_RJCT:
629 reason = cpu_to_le16(MESH_CAPABILITY_POLICY_VIOLATION);
630 case CLS_ACPT:
631 if (!reason)
632 reason = cpu_to_le16(MESH_CLOSE_RCVD);
633 sta->reason = reason;
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800634 sta->plink_state = PLINK_HOLDING;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100635 if (!mod_plink_timer(sta,
636 dot11MeshHoldingTimeout(sdata)))
637 sta->ignore_plink_timer = true;
638
639 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200640 spin_unlock_bh(&sta->lock);
Johannes Berg17741cd2008-09-11 00:02:02 +0200641 mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr, llid,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100642 plid, reason);
643 break;
644 case OPN_ACPT:
645 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200646 spin_unlock_bh(&sta->lock);
Johannes Berg17741cd2008-09-11 00:02:02 +0200647 mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr, llid,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100648 plid, 0);
649 break;
650 case CNF_ACPT:
Johannes Bergd0709a62008-02-25 16:27:46 +0100651 del_timer(&sta->plink_timer);
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800652 sta->plink_state = PLINK_ESTAB;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100653 mesh_plink_inc_estab_count(sdata);
Johannes Berg07346f812008-05-03 01:02:02 +0200654 spin_unlock_bh(&sta->lock);
Johannes Berg0c68ae262008-10-27 15:56:10 -0700655 mpl_dbg("Mesh plink with %pM ESTABLISHED\n",
656 sta->sta.addr);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100657 break;
658 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200659 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100660 break;
661 }
662 break;
663
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800664 case PLINK_CNF_RCVD:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100665 switch (event) {
666 case OPN_RJCT:
667 case CNF_RJCT:
668 reason = cpu_to_le16(MESH_CAPABILITY_POLICY_VIOLATION);
669 case CLS_ACPT:
670 if (!reason)
671 reason = cpu_to_le16(MESH_CLOSE_RCVD);
672 sta->reason = reason;
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800673 sta->plink_state = PLINK_HOLDING;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100674 if (!mod_plink_timer(sta,
675 dot11MeshHoldingTimeout(sdata)))
676 sta->ignore_plink_timer = true;
677
678 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200679 spin_unlock_bh(&sta->lock);
Johannes Berg17741cd2008-09-11 00:02:02 +0200680 mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr, llid,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100681 plid, reason);
Johannes Bergff59dc72008-02-25 10:11:50 +0100682 break;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100683 case OPN_ACPT:
Johannes Bergd0709a62008-02-25 16:27:46 +0100684 del_timer(&sta->plink_timer);
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800685 sta->plink_state = PLINK_ESTAB;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100686 mesh_plink_inc_estab_count(sdata);
Johannes Berg07346f812008-05-03 01:02:02 +0200687 spin_unlock_bh(&sta->lock);
Johannes Berg0c68ae262008-10-27 15:56:10 -0700688 mpl_dbg("Mesh plink with %pM ESTABLISHED\n",
689 sta->sta.addr);
Johannes Berg17741cd2008-09-11 00:02:02 +0200690 mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr, llid,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100691 plid, 0);
692 break;
693 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200694 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100695 break;
696 }
697 break;
698
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800699 case PLINK_ESTAB:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100700 switch (event) {
701 case CLS_ACPT:
702 reason = cpu_to_le16(MESH_CLOSE_RCVD);
703 sta->reason = reason;
Johannes Berg902acc72008-02-23 15:17:19 +0100704 __mesh_plink_deactivate(sta);
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800705 sta->plink_state = PLINK_HOLDING;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100706 llid = sta->llid;
Johannes Bergd0709a62008-02-25 16:27:46 +0100707 mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata));
Johannes Berg07346f812008-05-03 01:02:02 +0200708 spin_unlock_bh(&sta->lock);
Johannes Berg17741cd2008-09-11 00:02:02 +0200709 mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr, llid,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100710 plid, reason);
711 break;
712 case OPN_ACPT:
713 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200714 spin_unlock_bh(&sta->lock);
Johannes Berg17741cd2008-09-11 00:02:02 +0200715 mesh_plink_frame_tx(sdata, PLINK_CONFIRM, sta->sta.addr, llid,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100716 plid, 0);
717 break;
718 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200719 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100720 break;
721 }
722 break;
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800723 case PLINK_HOLDING:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100724 switch (event) {
725 case CLS_ACPT:
Johannes Bergd0709a62008-02-25 16:27:46 +0100726 if (del_timer(&sta->plink_timer))
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100727 sta->ignore_plink_timer = 1;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100728 mesh_plink_fsm_restart(sta);
Johannes Berg07346f812008-05-03 01:02:02 +0200729 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100730 break;
731 case OPN_ACPT:
732 case CNF_ACPT:
733 case OPN_RJCT:
734 case CNF_RJCT:
735 llid = sta->llid;
736 reason = sta->reason;
Johannes Berg07346f812008-05-03 01:02:02 +0200737 spin_unlock_bh(&sta->lock);
Johannes Berg17741cd2008-09-11 00:02:02 +0200738 mesh_plink_frame_tx(sdata, PLINK_CLOSE, sta->sta.addr,
739 llid, plid, reason);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100740 break;
741 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200742 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100743 }
744 break;
745 default:
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800746 /* should not get here, PLINK_BLOCKED is dealt with at the
747 * beggining of the function
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100748 */
Johannes Berg07346f812008-05-03 01:02:02 +0200749 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100750 break;
751 }
Johannes Bergd0709a62008-02-25 16:27:46 +0100752
753 rcu_read_unlock();
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100754}