blob: 9e0416696a834d1481a6f47385b97bbc8b4369db [file] [log] [blame]
Luis Carlos Coboc3896d22008-02-23 15:17:13 +01001/*
Rui Paulo264d9b72009-11-09 23:46:58 +00002 * Copyright (c) 2008, 2009 open80211s Ltd.
Luis Carlos Coboc3896d22008-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 */
Tejun Heo5a0e3ad2010-03-24 17:04:11 +09009#include <linux/gfp.h>
Johannes Berg902acc72008-02-23 15:17:19 +010010#include <linux/kernel.h>
11#include <linux/random.h>
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010012#include "ieee80211_i.h"
Johannes Berg2c8dccc2008-04-08 15:14:40 -040013#include "rate.h"
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010014#include "mesh.h"
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010015
Thomas Pedersen8db09852011-08-12 20:01:00 -070016#define PLINK_GET_LLID(p) (p + 2)
17#define PLINK_GET_PLID(p) (p + 4)
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010018
19#define mod_plink_timer(s, t) (mod_timer(&s->plink_timer, \
20 jiffies + HZ * t / 1000))
21
Ashok Nagarajan3d4f9692012-03-06 12:48:30 -080022/* We only need a valid sta if user configured a minimum rssi_threshold. */
23#define rssi_threshold_check(sta, sdata) \
Ashok Nagarajan55335132012-02-28 17:04:08 -080024 (sdata->u.mesh.mshcfg.rssi_threshold == 0 ||\
Ashok Nagarajan3d4f9692012-03-06 12:48:30 -080025 (sta && (s8) -ewma_read(&sta->avg_signal) > \
26 sdata->u.mesh.mshcfg.rssi_threshold))
Ashok Nagarajan55335132012-02-28 17:04:08 -080027
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010028enum plink_event {
29 PLINK_UNDEFINED,
30 OPN_ACPT,
31 OPN_RJCT,
32 OPN_IGNR,
33 CNF_ACPT,
34 CNF_RJCT,
35 CNF_IGNR,
36 CLS_ACPT,
37 CLS_IGNR
38};
39
Thomas Pedersenba4a14e2011-09-20 13:43:32 -070040static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
41 enum ieee80211_self_protected_actioncode action,
42 u8 *da, __le16 llid, __le16 plid, __le16 reason);
43
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010044/**
45 * mesh_plink_fsm_restart - restart a mesh peer link finite state machine
46 *
Rui Paulo23c7a292009-11-09 23:46:42 +000047 * @sta: mesh peer link to restart
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010048 *
Johannes Berg07346f812008-05-03 01:02:02 +020049 * Locking: this function must be called holding sta->lock
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010050 */
51static inline void mesh_plink_fsm_restart(struct sta_info *sta)
52{
Javier Cardona57cf8042011-05-13 10:45:43 -070053 sta->plink_state = NL80211_PLINK_LISTEN;
Luis Carlos Cobo37659ff2008-02-29 12:13:38 -080054 sta->llid = sta->plid = sta->reason = 0;
55 sta->plink_retries = 0;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010056}
57
Johannes Berg93e5deb2008-04-01 15:21:00 +020058/*
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -070059 * Allocate mesh sta entry and insert into station table
Johannes Berg93e5deb2008-04-01 15:21:00 +020060 */
Johannes Berg03e44972008-02-27 09:56:40 +010061static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -070062 u8 *hw_addr)
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010063{
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010064 struct sta_info *sta;
65
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -070066 if (sdata->local->num_sta >= MESH_MAX_PLINKS)
Johannes Berg73651ee2008-02-25 16:27:47 +010067 return NULL;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010068
Johannes Berg34e89502010-02-03 13:59:58 +010069 sta = sta_info_alloc(sdata, hw_addr, GFP_KERNEL);
Johannes Berg73651ee2008-02-25 16:27:47 +010070 if (!sta)
71 return NULL;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010072
Johannes Berg83d5cc02012-01-12 09:31:10 +010073 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
74 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
75 sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +010076
Johannes Bergc2c98fd2011-09-29 16:04:36 +020077 set_sta_flag(sta, WLAN_STA_WME);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +010078
Luis Carlos Coboc3896d22008-02-23 15:17:13 +010079 return sta;
80}
81
Ben Hutchings2c530402012-07-10 10:55:09 +000082/**
Ashok Nagarajancbf93222012-05-07 21:00:31 -070083 * mesh_set_ht_prot_mode - set correct HT protection mode
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -070084 *
Ashok Nagarajancbf93222012-05-07 21:00:31 -070085 * Section 9.23.3.5 of IEEE 80211-2012 describes the protection rules for HT
86 * mesh STA in a MBSS. Three HT protection modes are supported for now, non-HT
87 * mixed mode, 20MHz-protection and no-protection mode. non-HT mixed mode is
88 * selected if any non-HT peers are present in our MBSS. 20MHz-protection mode
89 * is selected if all peers in our 20/40MHz MBSS support HT and atleast one
90 * HT20 peer is present. Otherwise no-protection mode is selected.
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -070091 */
92static u32 mesh_set_ht_prot_mode(struct ieee80211_sub_if_data *sdata)
93{
94 struct ieee80211_local *local = sdata->local;
95 struct sta_info *sta;
96 u32 changed = 0;
97 u16 ht_opmode;
98 bool non_ht_sta = false, ht20_sta = false;
99
Johannes Berg4bf88532012-11-09 11:39:59 +0100100 if (sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700101 return 0;
102
103 rcu_read_lock();
104 list_for_each_entry_rcu(sta, &local->sta_list, list) {
Ashok Nagarajancbf93222012-05-07 21:00:31 -0700105 if (sdata != sta->sdata ||
106 sta->plink_state != NL80211_PLINK_ESTAB)
107 continue;
108
Johannes Berg4bf88532012-11-09 11:39:59 +0100109 switch (sta->ch_width) {
110 case NL80211_CHAN_WIDTH_20_NOHT:
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200111 mpl_dbg(sdata,
112 "mesh_plink %pM: nonHT sta (%pM) is present\n",
Ashok Nagarajancbf93222012-05-07 21:00:31 -0700113 sdata->vif.addr, sta->sta.addr);
114 non_ht_sta = true;
115 goto out;
Johannes Berg4bf88532012-11-09 11:39:59 +0100116 case NL80211_CHAN_WIDTH_20:
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200117 mpl_dbg(sdata,
118 "mesh_plink %pM: HT20 sta (%pM) is present\n",
Ashok Nagarajancbf93222012-05-07 21:00:31 -0700119 sdata->vif.addr, sta->sta.addr);
120 ht20_sta = true;
121 default:
122 break;
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700123 }
124 }
125out:
126 rcu_read_unlock();
127
128 if (non_ht_sta)
129 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
Johannes Berg466f3102012-07-25 13:51:49 +0200130 else if (ht20_sta &&
Johannes Berg4bf88532012-11-09 11:39:59 +0100131 sdata->vif.bss_conf.chandef.width > NL80211_CHAN_WIDTH_20)
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700132 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
133 else
134 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
135
136 if (sdata->vif.bss_conf.ht_operation_mode != ht_opmode) {
137 sdata->vif.bss_conf.ht_operation_mode = ht_opmode;
Ashok Nagarajan70c33ea2012-04-30 14:20:32 -0700138 sdata->u.mesh.mshcfg.ht_opmode = ht_opmode;
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700139 changed = BSS_CHANGED_HT;
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200140 mpl_dbg(sdata,
141 "mesh_plink %pM: protection mode changed to %d\n",
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700142 sdata->vif.addr, ht_opmode);
143 }
144
145 return changed;
146}
147
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100148/**
John W. Linvillec9370192010-06-21 17:14:07 -0400149 * __mesh_plink_deactivate - deactivate mesh peer link
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100150 *
151 * @sta: mesh peer link to deactivate
152 *
153 * All mesh paths with this peer as next hop will be flushed
Marco Porschdf323812012-08-08 07:58:43 +0200154 * Returns beacon changed flag if the beacon content changed.
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100155 *
Johannes Berg07346f812008-05-03 01:02:02 +0200156 * Locking: the caller must hold sta->lock
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100157 */
Marco Porschdf323812012-08-08 07:58:43 +0200158static u32 __mesh_plink_deactivate(struct sta_info *sta)
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100159{
Johannes Bergd0709a62008-02-25 16:27:46 +0100160 struct ieee80211_sub_if_data *sdata = sta->sdata;
Marco Porschdf323812012-08-08 07:58:43 +0200161 u32 changed = 0;
Johannes Bergd0709a62008-02-25 16:27:46 +0100162
Marco Porschdf323812012-08-08 07:58:43 +0200163 if (sta->plink_state == NL80211_PLINK_ESTAB)
164 changed = mesh_plink_dec_estab_count(sdata);
Javier Cardona57cf8042011-05-13 10:45:43 -0700165 sta->plink_state = NL80211_PLINK_BLOCKED;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100166 mesh_path_flush_by_nexthop(sta);
John W. Linvillec9370192010-06-21 17:14:07 -0400167
Marco Porschdf323812012-08-08 07:58:43 +0200168 return changed;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100169}
170
Johannes Berg902acc72008-02-23 15:17:19 +0100171/**
John W. Linvillec9370192010-06-21 17:14:07 -0400172 * mesh_plink_deactivate - deactivate mesh peer link
Johannes Berg902acc72008-02-23 15:17:19 +0100173 *
174 * @sta: mesh peer link to deactivate
175 *
176 * All mesh paths with this peer as next hop will be flushed
177 */
178void mesh_plink_deactivate(struct sta_info *sta)
179{
John W. Linvillec9370192010-06-21 17:14:07 -0400180 struct ieee80211_sub_if_data *sdata = sta->sdata;
Marco Porschdf323812012-08-08 07:58:43 +0200181 u32 changed;
John W. Linvillec9370192010-06-21 17:14:07 -0400182
Johannes Berg07346f812008-05-03 01:02:02 +0200183 spin_lock_bh(&sta->lock);
Marco Porschdf323812012-08-08 07:58:43 +0200184 changed = __mesh_plink_deactivate(sta);
Thomas Pedersenba4a14e2011-09-20 13:43:32 -0700185 sta->reason = cpu_to_le16(WLAN_REASON_MESH_PEER_CANCELED);
186 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
187 sta->sta.addr, sta->llid, sta->plid,
188 sta->reason);
Johannes Berg07346f812008-05-03 01:02:02 +0200189 spin_unlock_bh(&sta->lock);
John W. Linvillec9370192010-06-21 17:14:07 -0400190
Marco Porschdf323812012-08-08 07:58:43 +0200191 ieee80211_bss_info_change_notify(sdata, changed);
Johannes Berg902acc72008-02-23 15:17:19 +0100192}
193
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200194static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700195 enum ieee80211_self_protected_actioncode action,
196 u8 *da, __le16 llid, __le16 plid, __le16 reason) {
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200197 struct ieee80211_local *local = sdata->local;
Thomas Pedersen3b69a9c2011-10-26 14:47:25 -0700198 struct sk_buff *skb;
Thomas Pedersene7570df2012-08-03 12:21:34 -0700199 struct ieee80211_tx_info *info;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100200 struct ieee80211_mgmt *mgmt;
201 bool include_plid = false;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700202 u16 peering_proto = 0;
Thomas Pedersen3b69a9c2011-10-26 14:47:25 -0700203 u8 *pos, ie_len = 4;
204 int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.self_prot) +
205 sizeof(mgmt->u.action.u.self_prot);
Thomas Pedersenf609a432012-08-03 12:21:35 -0700206 int err = -ENOMEM;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100207
Javier Cardona65e8b0c2012-01-17 18:17:46 -0800208 skb = dev_alloc_skb(local->tx_headroom +
Thomas Pedersen3b69a9c2011-10-26 14:47:25 -0700209 hdr_len +
210 2 + /* capability info */
211 2 + /* AID */
212 2 + 8 + /* supported rates */
213 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
214 2 + sdata->u.mesh.mesh_id_len +
215 2 + sizeof(struct ieee80211_meshconf_ie) +
Thomas Pedersen176f3602011-10-26 14:47:27 -0700216 2 + sizeof(struct ieee80211_ht_cap) +
Johannes Berg074d46d2012-03-15 19:45:16 +0100217 2 + sizeof(struct ieee80211_ht_operation) +
Thomas Pedersen3b69a9c2011-10-26 14:47:25 -0700218 2 + 8 + /* peering IE */
219 sdata->u.mesh.ie_len);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100220 if (!skb)
221 return -1;
Thomas Pedersene7570df2012-08-03 12:21:34 -0700222 info = IEEE80211_SKB_CB(skb);
Javier Cardona65e8b0c2012-01-17 18:17:46 -0800223 skb_reserve(skb, local->tx_headroom);
Thomas Pedersen3b69a9c2011-10-26 14:47:25 -0700224 mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
225 memset(mgmt, 0, hdr_len);
Harvey Harrisone7827a72008-07-15 18:44:13 -0700226 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
227 IEEE80211_STYPE_ACTION);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100228 memcpy(mgmt->da, da, ETH_ALEN);
Johannes Berg47846c92009-11-25 17:46:19 +0100229 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
Javier Cardona915b5c52011-05-03 16:57:10 -0700230 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700231 mgmt->u.action.category = WLAN_CATEGORY_SELF_PROTECTED;
232 mgmt->u.action.u.self_prot.action_code = action;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100233
Thomas Pedersen8db09852011-08-12 20:01:00 -0700234 if (action != WLAN_SP_MESH_PEERING_CLOSE) {
Johannes Berg55de9082012-07-26 17:24:39 +0200235 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
236
Thomas Pedersen8db09852011-08-12 20:01:00 -0700237 /* capability info */
238 pos = skb_put(skb, 2);
239 memset(pos, 0, 2);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700240 if (action == WLAN_SP_MESH_PEERING_CONFIRM) {
Thomas Pedersen8db09852011-08-12 20:01:00 -0700241 /* AID */
242 pos = skb_put(skb, 2);
Rui Paulo77fa76b2009-11-09 23:46:52 +0000243 memcpy(pos + 2, &plid, 2);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100244 }
Johannes Berg55de9082012-07-26 17:24:39 +0200245 if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
246 ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
Thomas Pedersen082ebb02011-08-11 19:35:10 -0700247 mesh_add_rsn_ie(skb, sdata) ||
248 mesh_add_meshid_ie(skb, sdata) ||
249 mesh_add_meshconf_ie(skb, sdata))
Thomas Pedersenf609a432012-08-03 12:21:35 -0700250 goto free;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700251 } else { /* WLAN_SP_MESH_PEERING_CLOSE */
Thomas Pedersene7570df2012-08-03 12:21:34 -0700252 info->flags |= IEEE80211_TX_CTL_NO_ACK;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700253 if (mesh_add_meshid_ie(skb, sdata))
Thomas Pedersenf609a432012-08-03 12:21:35 -0700254 goto free;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100255 }
256
Thomas Pedersen8db09852011-08-12 20:01:00 -0700257 /* Add Mesh Peering Management element */
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100258 switch (action) {
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700259 case WLAN_SP_MESH_PEERING_OPEN:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100260 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700261 case WLAN_SP_MESH_PEERING_CONFIRM:
Thomas Pedersen8db09852011-08-12 20:01:00 -0700262 ie_len += 2;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100263 include_plid = true;
264 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700265 case WLAN_SP_MESH_PEERING_CLOSE:
Thomas Pedersen8db09852011-08-12 20:01:00 -0700266 if (plid) {
267 ie_len += 2;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100268 include_plid = true;
269 }
Thomas Pedersen8db09852011-08-12 20:01:00 -0700270 ie_len += 2; /* reason code */
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100271 break;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700272 default:
Thomas Pedersenf609a432012-08-03 12:21:35 -0700273 err = -EINVAL;
274 goto free;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100275 }
276
Thomas Pedersen8db09852011-08-12 20:01:00 -0700277 if (WARN_ON(skb_tailroom(skb) < 2 + ie_len))
Thomas Pedersenf609a432012-08-03 12:21:35 -0700278 goto free;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700279
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100280 pos = skb_put(skb, 2 + ie_len);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700281 *pos++ = WLAN_EID_PEER_MGMT;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100282 *pos++ = ie_len;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700283 memcpy(pos, &peering_proto, 2);
284 pos += 2;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100285 memcpy(pos, &llid, 2);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700286 pos += 2;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100287 if (include_plid) {
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100288 memcpy(pos, &plid, 2);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700289 pos += 2;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100290 }
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700291 if (action == WLAN_SP_MESH_PEERING_CLOSE) {
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100292 memcpy(pos, &reason, 2);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700293 pos += 2;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100294 }
Thomas Pedersen176f3602011-10-26 14:47:27 -0700295
296 if (action != WLAN_SP_MESH_PEERING_CLOSE) {
297 if (mesh_add_ht_cap_ie(skb, sdata) ||
Johannes Berg074d46d2012-03-15 19:45:16 +0100298 mesh_add_ht_oper_ie(skb, sdata))
Thomas Pedersenf609a432012-08-03 12:21:35 -0700299 goto free;
Thomas Pedersen176f3602011-10-26 14:47:27 -0700300 }
301
Thomas Pedersen8db09852011-08-12 20:01:00 -0700302 if (mesh_add_vendor_ies(skb, sdata))
Thomas Pedersenf609a432012-08-03 12:21:35 -0700303 goto free;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100304
Johannes Berg62ae67b2009-11-18 18:42:05 +0100305 ieee80211_tx_skb(sdata, skb);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100306 return 0;
Thomas Pedersenf609a432012-08-03 12:21:35 -0700307free:
308 kfree_skb(skb);
309 return err;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100310}
311
Ben Hutchings2c530402012-07-10 10:55:09 +0000312/**
313 * mesh_peer_init - initialize new mesh peer and return resulting sta_info
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700314 *
315 * @sdata: local meshif
316 * @addr: peer's address
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700317 * @elems: IEs from beacon or mesh peering frame
318 *
319 * call under RCU
320 */
321static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata,
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700322 u8 *addr,
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700323 struct ieee802_11_elems *elems)
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100324{
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200325 struct ieee80211_local *local = sdata->local;
Johannes Berg55de9082012-07-26 17:24:39 +0200326 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700327 struct ieee80211_supported_band *sband;
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700328 u32 rates, basic_rates = 0;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100329 struct sta_info *sta;
Thomas Pedersene87278e2012-04-26 15:01:06 -0700330 bool insert = false;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100331
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700332 sband = local->hw.wiphy->bands[band];
333 rates = ieee80211_sta_get_rates(local, elems, band, &basic_rates);
Johannes Bergd0709a62008-02-25 16:27:46 +0100334
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700335 sta = sta_info_get(sdata, addr);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100336 if (!sta) {
Thomas Pedersenf5c56812012-05-03 15:06:09 -0700337 /* Userspace handles peer allocation when security is enabled */
338 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED) {
339 cfg80211_notify_new_peer_candidate(sdata->dev, addr,
340 elems->ie_start,
341 elems->total_len,
342 GFP_ATOMIC);
343 return NULL;
344 }
345
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700346 sta = mesh_plink_alloc(sdata, addr);
Johannes Berg34e89502010-02-03 13:59:58 +0100347 if (!sta)
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700348 return NULL;
Thomas Pedersene87278e2012-04-26 15:01:06 -0700349 insert = true;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100350 }
351
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700352 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100353 sta->last_rx = jiffies;
Chun-Yeow Yeohbae35d92012-07-24 11:52:35 +0800354 if (sta->plink_state == NL80211_PLINK_ESTAB) {
355 spin_unlock_bh(&sta->lock);
356 return sta;
357 }
358
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700359 sta->sta.supp_rates[band] = rates;
Thomas Pedersene76781e2012-04-18 19:24:13 -0700360 if (elems->ht_cap_elem &&
Johannes Berg4bf88532012-11-09 11:39:59 +0100361 sdata->vif.bss_conf.chandef.width != NL80211_CHAN_WIDTH_20_NOHT)
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700362 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
363 elems->ht_cap_elem,
364 &sta->sta.ht_cap);
365 else
366 memset(&sta->sta.ht_cap, 0, sizeof(sta->sta.ht_cap));
367
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700368 if (elems->ht_operation) {
Johannes Berg4bf88532012-11-09 11:39:59 +0100369 struct cfg80211_chan_def chandef;
370
Thomas Pedersenc7d25822012-04-26 15:01:07 -0700371 if (!(elems->ht_operation->ht_param &
372 IEEE80211_HT_PARAM_CHAN_WIDTH_ANY))
373 sta->sta.ht_cap.cap &=
374 ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
Johannes Berg4bf88532012-11-09 11:39:59 +0100375 ieee80211_ht_oper_to_chandef(sdata->vif.bss_conf.chandef.chan,
376 elems->ht_operation, &chandef);
377 sta->ch_width = chandef.width;
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700378 }
Thomas Pedersenc7d25822012-04-26 15:01:07 -0700379
Helmut Schaa59cf1d62012-11-27 18:03:13 +0100380 if (insert)
381 rate_control_rate_init(sta);
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700382 spin_unlock_bh(&sta->lock);
383
Thomas Pedersene87278e2012-04-26 15:01:06 -0700384 if (insert && sta_info_insert(sta))
385 return NULL;
386
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700387 return sta;
388}
389
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700390void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
391 u8 *hw_addr,
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700392 struct ieee802_11_elems *elems)
393{
394 struct sta_info *sta;
395
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700396 rcu_read_lock();
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700397 sta = mesh_peer_init(sdata, hw_addr, elems);
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700398 if (!sta)
399 goto out;
400
Javier Cardona1570ca52011-04-07 15:08:35 -0700401 if (mesh_peer_accepts_plinks(elems) &&
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700402 sta->plink_state == NL80211_PLINK_LISTEN &&
403 sdata->u.mesh.accepting_plinks &&
404 sdata->u.mesh.mshcfg.auto_open_plinks &&
405 rssi_threshold_check(sta, sdata))
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100406 mesh_plink_open(sta);
407
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700408out:
Johannes Bergd0709a62008-02-25 16:27:46 +0100409 rcu_read_unlock();
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100410}
411
412static void mesh_plink_timer(unsigned long data)
413{
414 struct sta_info *sta;
415 __le16 llid, plid, reason;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100416 struct ieee80211_sub_if_data *sdata;
Marco Porsch453e66f22012-11-21 18:40:32 -0800417 struct mesh_config *mshcfg;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100418
Johannes Bergd0709a62008-02-25 16:27:46 +0100419 /*
420 * This STA is valid because sta_info_destroy() will
421 * del_timer_sync() this timer after having made sure
422 * it cannot be readded (by deleting the plink.)
423 */
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100424 sta = (struct sta_info *) data;
425
Johannes Berg5bb644a2009-05-17 11:40:42 +0200426 if (sta->sdata->local->quiescing) {
427 sta->plink_timer_was_running = true;
428 return;
429 }
430
Johannes Berg07346f812008-05-03 01:02:02 +0200431 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100432 if (sta->ignore_plink_timer) {
433 sta->ignore_plink_timer = false;
Johannes Berg07346f812008-05-03 01:02:02 +0200434 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100435 return;
436 }
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200437 mpl_dbg(sta->sdata,
438 "Mesh plink timer for %pM fired on state %d\n",
Johannes Berg0c68ae262008-10-27 15:56:10 -0700439 sta->sta.addr, sta->plink_state);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100440 reason = 0;
441 llid = sta->llid;
442 plid = sta->plid;
Johannes Bergd0709a62008-02-25 16:27:46 +0100443 sdata = sta->sdata;
Marco Porsch453e66f22012-11-21 18:40:32 -0800444 mshcfg = &sdata->u.mesh.mshcfg;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100445
446 switch (sta->plink_state) {
Javier Cardona57cf8042011-05-13 10:45:43 -0700447 case NL80211_PLINK_OPN_RCVD:
448 case NL80211_PLINK_OPN_SNT:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100449 /* retry timer */
Marco Porsch453e66f22012-11-21 18:40:32 -0800450 if (sta->plink_retries < mshcfg->dot11MeshMaxRetries) {
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100451 u32 rand;
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200452 mpl_dbg(sta->sdata,
453 "Mesh plink for %pM (retry, timeout): %d %d\n",
Johannes Berg0c68ae262008-10-27 15:56:10 -0700454 sta->sta.addr, sta->plink_retries,
455 sta->plink_timeout);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100456 get_random_bytes(&rand, sizeof(u32));
457 sta->plink_timeout = sta->plink_timeout +
458 rand % sta->plink_timeout;
459 ++sta->plink_retries;
Johannes Bergd0709a62008-02-25 16:27:46 +0100460 mod_plink_timer(sta, sta->plink_timeout);
Johannes Berg07346f812008-05-03 01:02:02 +0200461 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700462 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_OPEN,
463 sta->sta.addr, llid, 0, 0);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100464 break;
465 }
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700466 reason = cpu_to_le16(WLAN_REASON_MESH_MAX_RETRIES);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100467 /* fall through on else */
Javier Cardona57cf8042011-05-13 10:45:43 -0700468 case NL80211_PLINK_CNF_RCVD:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100469 /* confirm timer */
470 if (!reason)
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700471 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIRM_TIMEOUT);
Javier Cardona57cf8042011-05-13 10:45:43 -0700472 sta->plink_state = NL80211_PLINK_HOLDING;
Marco Porsch453e66f22012-11-21 18:40:32 -0800473 mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout);
Johannes Berg07346f812008-05-03 01:02:02 +0200474 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700475 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
476 sta->sta.addr, llid, plid, reason);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100477 break;
Javier Cardona57cf8042011-05-13 10:45:43 -0700478 case NL80211_PLINK_HOLDING:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100479 /* holding timer */
Johannes Bergd0709a62008-02-25 16:27:46 +0100480 del_timer(&sta->plink_timer);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100481 mesh_plink_fsm_restart(sta);
Johannes Berg07346f812008-05-03 01:02:02 +0200482 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100483 break;
484 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200485 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100486 break;
487 }
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100488}
489
Johannes Berg5bb644a2009-05-17 11:40:42 +0200490#ifdef CONFIG_PM
491void mesh_plink_quiesce(struct sta_info *sta)
492{
493 if (del_timer_sync(&sta->plink_timer))
494 sta->plink_timer_was_running = true;
495}
496
497void mesh_plink_restart(struct sta_info *sta)
498{
499 if (sta->plink_timer_was_running) {
500 add_timer(&sta->plink_timer);
501 sta->plink_timer_was_running = false;
502 }
503}
504#endif
505
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100506static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout)
507{
508 sta->plink_timer.expires = jiffies + (HZ * timeout / 1000);
509 sta->plink_timer.data = (unsigned long) sta;
510 sta->plink_timer.function = mesh_plink_timer;
511 sta->plink_timeout = timeout;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100512 add_timer(&sta->plink_timer);
513}
514
515int mesh_plink_open(struct sta_info *sta)
516{
517 __le16 llid;
Johannes Bergd0709a62008-02-25 16:27:46 +0100518 struct ieee80211_sub_if_data *sdata = sta->sdata;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100519
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200520 if (!test_sta_flag(sta, WLAN_STA_AUTH))
Javier Cardona53e80512011-04-07 15:08:32 -0700521 return -EPERM;
522
Johannes Berg07346f812008-05-03 01:02:02 +0200523 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100524 get_random_bytes(&llid, 2);
525 sta->llid = llid;
Chun-Yeow Yeoh9385d042012-09-14 14:18:31 +0800526 if (sta->plink_state != NL80211_PLINK_LISTEN &&
527 sta->plink_state != NL80211_PLINK_BLOCKED) {
Johannes Berg07346f812008-05-03 01:02:02 +0200528 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100529 return -EBUSY;
530 }
Javier Cardona57cf8042011-05-13 10:45:43 -0700531 sta->plink_state = NL80211_PLINK_OPN_SNT;
Marco Porsch453e66f22012-11-21 18:40:32 -0800532 mesh_plink_timer_set(sta, sdata->u.mesh.mshcfg.dot11MeshRetryTimeout);
Johannes Berg07346f812008-05-03 01:02:02 +0200533 spin_unlock_bh(&sta->lock);
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200534 mpl_dbg(sdata,
535 "Mesh plink: starting establishment with %pM\n",
Johannes Berg0c68ae262008-10-27 15:56:10 -0700536 sta->sta.addr);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100537
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700538 return mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_OPEN,
Johannes Berg17741cd2008-09-11 00:02:02 +0200539 sta->sta.addr, llid, 0, 0);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100540}
541
542void mesh_plink_block(struct sta_info *sta)
543{
John W. Linvillec9370192010-06-21 17:14:07 -0400544 struct ieee80211_sub_if_data *sdata = sta->sdata;
Marco Porschdf323812012-08-08 07:58:43 +0200545 u32 changed;
John W. Linvillec9370192010-06-21 17:14:07 -0400546
Johannes Berg07346f812008-05-03 01:02:02 +0200547 spin_lock_bh(&sta->lock);
Marco Porschdf323812012-08-08 07:58:43 +0200548 changed = __mesh_plink_deactivate(sta);
Javier Cardona57cf8042011-05-13 10:45:43 -0700549 sta->plink_state = NL80211_PLINK_BLOCKED;
Johannes Berg07346f812008-05-03 01:02:02 +0200550 spin_unlock_bh(&sta->lock);
John W. Linvillec9370192010-06-21 17:14:07 -0400551
Marco Porschdf323812012-08-08 07:58:43 +0200552 ieee80211_bss_info_change_notify(sdata, changed);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100553}
554
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100555
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200556void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt,
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100557 size_t len, struct ieee80211_rx_status *rx_status)
558{
Marco Porsch453e66f22012-11-21 18:40:32 -0800559 struct mesh_config *mshcfg = &sdata->u.mesh.mshcfg;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100560 struct ieee802_11_elems elems;
561 struct sta_info *sta;
562 enum plink_event event;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700563 enum ieee80211_self_protected_actioncode ftype;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100564 size_t baselen;
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700565 bool matches_local = true;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100566 u8 ie_len;
567 u8 *baseaddr;
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700568 u32 changed = 0;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100569 __le16 plid, llid, reason;
Rui Paulo1460dd12009-11-09 23:46:48 +0000570 static const char *mplstates[] = {
Javier Cardona57cf8042011-05-13 10:45:43 -0700571 [NL80211_PLINK_LISTEN] = "LISTEN",
572 [NL80211_PLINK_OPN_SNT] = "OPN-SNT",
573 [NL80211_PLINK_OPN_RCVD] = "OPN-RCVD",
574 [NL80211_PLINK_CNF_RCVD] = "CNF_RCVD",
575 [NL80211_PLINK_ESTAB] = "ESTAB",
576 [NL80211_PLINK_HOLDING] = "HOLDING",
577 [NL80211_PLINK_BLOCKED] = "BLOCKED"
Rui Paulo1460dd12009-11-09 23:46:48 +0000578 };
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100579
Johannes Berg9c80d3d2008-09-08 15:41:59 +0200580 /* need action_code, aux */
581 if (len < IEEE80211_MIN_ACTION_SIZE + 3)
582 return;
583
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100584 if (is_multicast_ether_addr(mgmt->da)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200585 mpl_dbg(sdata,
586 "Mesh plink: ignore frame from multicast address\n");
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100587 return;
588 }
589
Thomas Pedersen8db09852011-08-12 20:01:00 -0700590 baseaddr = mgmt->u.action.u.self_prot.variable;
591 baselen = (u8 *) mgmt->u.action.u.self_prot.variable - (u8 *) mgmt;
592 if (mgmt->u.action.u.self_prot.action_code ==
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700593 WLAN_SP_MESH_PEERING_CONFIRM) {
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100594 baseaddr += 4;
David Woo70bdb6b2009-08-12 11:03:44 -0700595 baselen += 4;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100596 }
597 ieee802_11_parse_elems(baseaddr, len - baselen, &elems);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700598 if (!elems.peering) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200599 mpl_dbg(sdata,
600 "Mesh plink: missing necessary peer link ie\n");
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100601 return;
602 }
Javier Cardonab130e5c2011-05-03 16:57:07 -0700603 if (elems.rsn_len &&
604 sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200605 mpl_dbg(sdata,
606 "Mesh plink: can't establish link with secure peer\n");
Javier Cardona5cff5e02011-04-07 15:08:29 -0700607 return;
608 }
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100609
Thomas Pedersen8db09852011-08-12 20:01:00 -0700610 ftype = mgmt->u.action.u.self_prot.action_code;
611 ie_len = elems.peering_len;
612 if ((ftype == WLAN_SP_MESH_PEERING_OPEN && ie_len != 4) ||
613 (ftype == WLAN_SP_MESH_PEERING_CONFIRM && ie_len != 6) ||
614 (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len != 6
615 && ie_len != 8)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200616 mpl_dbg(sdata,
617 "Mesh plink: incorrect plink ie length %d %d\n",
618 ftype, ie_len);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100619 return;
620 }
621
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700622 if (ftype != WLAN_SP_MESH_PEERING_CLOSE &&
623 (!elems.mesh_id || !elems.mesh_config)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200624 mpl_dbg(sdata, "Mesh plink: missing necessary ie\n");
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100625 return;
626 }
627 /* Note the lines below are correct, the llid in the frame is the plid
628 * from the point of view of this host.
629 */
Thomas Pedersen8db09852011-08-12 20:01:00 -0700630 memcpy(&plid, PLINK_GET_LLID(elems.peering), 2);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700631 if (ftype == WLAN_SP_MESH_PEERING_CONFIRM ||
Thomas Pedersen8db09852011-08-12 20:01:00 -0700632 (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len == 8))
633 memcpy(&llid, PLINK_GET_PLID(elems.peering), 2);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100634
Johannes Bergd0709a62008-02-25 16:27:46 +0100635 rcu_read_lock();
636
Johannes Bergabe60632009-11-25 17:46:18 +0100637 sta = sta_info_get(sdata, mgmt->sa);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700638 if (!sta && ftype != WLAN_SP_MESH_PEERING_OPEN) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200639 mpl_dbg(sdata, "Mesh plink: cls or cnf from unknown peer\n");
Johannes Bergd0709a62008-02-25 16:27:46 +0100640 rcu_read_unlock();
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100641 return;
642 }
643
Ashok Nagarajan55335132012-02-28 17:04:08 -0800644 if (ftype == WLAN_SP_MESH_PEERING_OPEN &&
Ashok Nagarajan3d4f9692012-03-06 12:48:30 -0800645 !rssi_threshold_check(sta, sdata)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200646 mpl_dbg(sdata, "Mesh plink: %pM does not meet rssi threshold\n",
Ashok Nagarajan3d4f9692012-03-06 12:48:30 -0800647 mgmt->sa);
Ashok Nagarajan55335132012-02-28 17:04:08 -0800648 rcu_read_unlock();
649 return;
650 }
651
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200652 if (sta && !test_sta_flag(sta, WLAN_STA_AUTH)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200653 mpl_dbg(sdata, "Mesh plink: Action frame from non-authed peer\n");
Javier Cardona53e80512011-04-07 15:08:32 -0700654 rcu_read_unlock();
655 return;
656 }
657
Javier Cardona57cf8042011-05-13 10:45:43 -0700658 if (sta && sta->plink_state == NL80211_PLINK_BLOCKED) {
Johannes Bergd0709a62008-02-25 16:27:46 +0100659 rcu_read_unlock();
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100660 return;
661 }
662
663 /* Now we will figure out the appropriate event... */
664 event = PLINK_UNDEFINED;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700665 if (ftype != WLAN_SP_MESH_PEERING_CLOSE &&
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700666 !mesh_matches_local(sdata, &elems)) {
Christian Lamparterd12c7452010-10-08 22:27:07 +0200667 matches_local = false;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100668 switch (ftype) {
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700669 case WLAN_SP_MESH_PEERING_OPEN:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100670 event = OPN_RJCT;
671 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700672 case WLAN_SP_MESH_PEERING_CONFIRM:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100673 event = CNF_RJCT;
674 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700675 default:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100676 break;
677 }
Christian Lamparterd12c7452010-10-08 22:27:07 +0200678 }
679
680 if (!sta && !matches_local) {
681 rcu_read_unlock();
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700682 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
Christian Lamparterd12c7452010-10-08 22:27:07 +0200683 llid = 0;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700684 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
685 mgmt->sa, llid, plid, reason);
Christian Lamparterd12c7452010-10-08 22:27:07 +0200686 return;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100687 } else if (!sta) {
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700688 /* ftype == WLAN_SP_MESH_PEERING_OPEN */
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100689 if (!mesh_plink_free_count(sdata)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200690 mpl_dbg(sdata, "Mesh plink error: no more free plinks\n");
Johannes Berg73651ee2008-02-25 16:27:47 +0100691 rcu_read_unlock();
692 return;
693 }
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100694 event = OPN_ACPT;
Christian Lamparterd12c7452010-10-08 22:27:07 +0200695 } else if (matches_local) {
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100696 switch (ftype) {
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700697 case WLAN_SP_MESH_PEERING_OPEN:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100698 if (!mesh_plink_free_count(sdata) ||
Johannes Bergd0709a62008-02-25 16:27:46 +0100699 (sta->plid && sta->plid != plid))
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100700 event = OPN_IGNR;
701 else
702 event = OPN_ACPT;
703 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700704 case WLAN_SP_MESH_PEERING_CONFIRM:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100705 if (!mesh_plink_free_count(sdata) ||
Johannes Bergd0709a62008-02-25 16:27:46 +0100706 (sta->llid != llid || sta->plid != plid))
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100707 event = CNF_IGNR;
708 else
709 event = CNF_ACPT;
710 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700711 case WLAN_SP_MESH_PEERING_CLOSE:
Javier Cardona57cf8042011-05-13 10:45:43 -0700712 if (sta->plink_state == NL80211_PLINK_ESTAB)
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100713 /* Do not check for llid or plid. This does not
714 * follow the standard but since multiple plinks
715 * per sta are not supported, it is necessary in
716 * order to avoid a livelock when MP A sees an
717 * establish peer link to MP B but MP B does not
718 * see it. This can be caused by a timeout in
719 * B's peer link establishment or B beign
720 * restarted.
721 */
722 event = CLS_ACPT;
723 else if (sta->plid != plid)
724 event = CLS_IGNR;
725 else if (ie_len == 7 && sta->llid != llid)
726 event = CLS_IGNR;
727 else
728 event = CLS_ACPT;
729 break;
730 default:
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200731 mpl_dbg(sdata, "Mesh plink: unknown frame subtype\n");
Johannes Bergd0709a62008-02-25 16:27:46 +0100732 rcu_read_unlock();
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100733 return;
734 }
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700735 }
736
737 if (event == OPN_ACPT) {
738 /* allocate sta entry if necessary and update info */
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700739 sta = mesh_peer_init(sdata, mgmt->sa, &elems);
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700740 if (!sta) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200741 mpl_dbg(sdata, "Mesh plink: failed to init peer!\n");
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700742 rcu_read_unlock();
743 return;
744 }
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100745 }
746
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200747 mpl_dbg(sdata,
748 "Mesh plink (peer, state, llid, plid, event): %pM %s %d %d %d\n",
Rui Paulo1460dd12009-11-09 23:46:48 +0000749 mgmt->sa, mplstates[sta->plink_state],
Johannes Berg0c68ae262008-10-27 15:56:10 -0700750 le16_to_cpu(sta->llid), le16_to_cpu(sta->plid),
751 event);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100752 reason = 0;
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700753 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100754 switch (sta->plink_state) {
755 /* spin_unlock as soon as state is updated at each case */
Javier Cardona57cf8042011-05-13 10:45:43 -0700756 case NL80211_PLINK_LISTEN:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100757 switch (event) {
758 case CLS_ACPT:
759 mesh_plink_fsm_restart(sta);
Johannes Berg07346f812008-05-03 01:02:02 +0200760 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100761 break;
762 case OPN_ACPT:
Javier Cardona57cf8042011-05-13 10:45:43 -0700763 sta->plink_state = NL80211_PLINK_OPN_RCVD;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100764 sta->plid = plid;
765 get_random_bytes(&llid, 2);
766 sta->llid = llid;
Marco Porsch453e66f22012-11-21 18:40:32 -0800767 mesh_plink_timer_set(sta,
768 mshcfg->dot11MeshRetryTimeout);
Johannes Berg07346f812008-05-03 01:02:02 +0200769 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700770 mesh_plink_frame_tx(sdata,
771 WLAN_SP_MESH_PEERING_OPEN,
772 sta->sta.addr, llid, 0, 0);
773 mesh_plink_frame_tx(sdata,
774 WLAN_SP_MESH_PEERING_CONFIRM,
775 sta->sta.addr, llid, plid, 0);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100776 break;
777 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200778 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100779 break;
780 }
781 break;
782
Javier Cardona57cf8042011-05-13 10:45:43 -0700783 case NL80211_PLINK_OPN_SNT:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100784 switch (event) {
785 case OPN_RJCT:
786 case CNF_RJCT:
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700787 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100788 case CLS_ACPT:
789 if (!reason)
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700790 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100791 sta->reason = reason;
Javier Cardona57cf8042011-05-13 10:45:43 -0700792 sta->plink_state = NL80211_PLINK_HOLDING;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100793 if (!mod_plink_timer(sta,
Marco Porsch453e66f22012-11-21 18:40:32 -0800794 mshcfg->dot11MeshHoldingTimeout))
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100795 sta->ignore_plink_timer = true;
796
797 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200798 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700799 mesh_plink_frame_tx(sdata,
800 WLAN_SP_MESH_PEERING_CLOSE,
801 sta->sta.addr, llid, plid, reason);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100802 break;
803 case OPN_ACPT:
804 /* retry timer is left untouched */
Javier Cardona57cf8042011-05-13 10:45:43 -0700805 sta->plink_state = NL80211_PLINK_OPN_RCVD;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100806 sta->plid = plid;
807 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200808 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700809 mesh_plink_frame_tx(sdata,
810 WLAN_SP_MESH_PEERING_CONFIRM,
811 sta->sta.addr, llid, plid, 0);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100812 break;
813 case CNF_ACPT:
Javier Cardona57cf8042011-05-13 10:45:43 -0700814 sta->plink_state = NL80211_PLINK_CNF_RCVD;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100815 if (!mod_plink_timer(sta,
Marco Porsch453e66f22012-11-21 18:40:32 -0800816 mshcfg->dot11MeshConfirmTimeout))
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100817 sta->ignore_plink_timer = true;
818
Johannes Berg07346f812008-05-03 01:02:02 +0200819 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100820 break;
821 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200822 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100823 break;
824 }
825 break;
826
Javier Cardona57cf8042011-05-13 10:45:43 -0700827 case NL80211_PLINK_OPN_RCVD:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100828 switch (event) {
829 case OPN_RJCT:
830 case CNF_RJCT:
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700831 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100832 case CLS_ACPT:
833 if (!reason)
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700834 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100835 sta->reason = reason;
Javier Cardona57cf8042011-05-13 10:45:43 -0700836 sta->plink_state = NL80211_PLINK_HOLDING;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100837 if (!mod_plink_timer(sta,
Marco Porsch453e66f22012-11-21 18:40:32 -0800838 mshcfg->dot11MeshHoldingTimeout))
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100839 sta->ignore_plink_timer = true;
840
841 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200842 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700843 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
844 sta->sta.addr, llid, plid, reason);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100845 break;
846 case OPN_ACPT:
847 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200848 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700849 mesh_plink_frame_tx(sdata,
850 WLAN_SP_MESH_PEERING_CONFIRM,
851 sta->sta.addr, llid, plid, 0);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100852 break;
853 case CNF_ACPT:
Johannes Bergd0709a62008-02-25 16:27:46 +0100854 del_timer(&sta->plink_timer);
Javier Cardona57cf8042011-05-13 10:45:43 -0700855 sta->plink_state = NL80211_PLINK_ESTAB;
Johannes Berg07346f812008-05-03 01:02:02 +0200856 spin_unlock_bh(&sta->lock);
Marco Porschdf323812012-08-08 07:58:43 +0200857 changed |= mesh_plink_inc_estab_count(sdata);
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700858 changed |= mesh_set_ht_prot_mode(sdata);
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200859 mpl_dbg(sdata, "Mesh plink with %pM ESTABLISHED\n",
Johannes Berg0c68ae262008-10-27 15:56:10 -0700860 sta->sta.addr);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100861 break;
862 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200863 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100864 break;
865 }
866 break;
867
Javier Cardona57cf8042011-05-13 10:45:43 -0700868 case NL80211_PLINK_CNF_RCVD:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100869 switch (event) {
870 case OPN_RJCT:
871 case CNF_RJCT:
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700872 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100873 case CLS_ACPT:
874 if (!reason)
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700875 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100876 sta->reason = reason;
Javier Cardona57cf8042011-05-13 10:45:43 -0700877 sta->plink_state = NL80211_PLINK_HOLDING;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100878 if (!mod_plink_timer(sta,
Marco Porsch453e66f22012-11-21 18:40:32 -0800879 mshcfg->dot11MeshHoldingTimeout))
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100880 sta->ignore_plink_timer = true;
881
882 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200883 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700884 mesh_plink_frame_tx(sdata,
885 WLAN_SP_MESH_PEERING_CLOSE,
886 sta->sta.addr, llid, plid, reason);
Johannes Bergff59dc72008-02-25 10:11:50 +0100887 break;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100888 case OPN_ACPT:
Johannes Bergd0709a62008-02-25 16:27:46 +0100889 del_timer(&sta->plink_timer);
Javier Cardona57cf8042011-05-13 10:45:43 -0700890 sta->plink_state = NL80211_PLINK_ESTAB;
Johannes Berg07346f812008-05-03 01:02:02 +0200891 spin_unlock_bh(&sta->lock);
Marco Porschdf323812012-08-08 07:58:43 +0200892 changed |= mesh_plink_inc_estab_count(sdata);
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700893 changed |= mesh_set_ht_prot_mode(sdata);
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200894 mpl_dbg(sdata, "Mesh plink with %pM ESTABLISHED\n",
Johannes Berg0c68ae262008-10-27 15:56:10 -0700895 sta->sta.addr);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700896 mesh_plink_frame_tx(sdata,
897 WLAN_SP_MESH_PEERING_CONFIRM,
898 sta->sta.addr, llid, plid, 0);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100899 break;
900 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200901 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100902 break;
903 }
904 break;
905
Javier Cardona57cf8042011-05-13 10:45:43 -0700906 case NL80211_PLINK_ESTAB:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100907 switch (event) {
908 case CLS_ACPT:
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700909 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100910 sta->reason = reason;
Marco Porschdf323812012-08-08 07:58:43 +0200911 changed |= __mesh_plink_deactivate(sta);
Javier Cardona57cf8042011-05-13 10:45:43 -0700912 sta->plink_state = NL80211_PLINK_HOLDING;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100913 llid = sta->llid;
Marco Porsch453e66f22012-11-21 18:40:32 -0800914 mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout);
Johannes Berg07346f812008-05-03 01:02:02 +0200915 spin_unlock_bh(&sta->lock);
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700916 changed |= mesh_set_ht_prot_mode(sdata);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700917 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
918 sta->sta.addr, llid, plid, reason);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100919 break;
920 case OPN_ACPT:
921 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200922 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700923 mesh_plink_frame_tx(sdata,
924 WLAN_SP_MESH_PEERING_CONFIRM,
925 sta->sta.addr, llid, plid, 0);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100926 break;
927 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200928 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100929 break;
930 }
931 break;
Javier Cardona57cf8042011-05-13 10:45:43 -0700932 case NL80211_PLINK_HOLDING:
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100933 switch (event) {
934 case CLS_ACPT:
Johannes Bergd0709a62008-02-25 16:27:46 +0100935 if (del_timer(&sta->plink_timer))
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100936 sta->ignore_plink_timer = 1;
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100937 mesh_plink_fsm_restart(sta);
Johannes Berg07346f812008-05-03 01:02:02 +0200938 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100939 break;
940 case OPN_ACPT:
941 case CNF_ACPT:
942 case OPN_RJCT:
943 case CNF_RJCT:
944 llid = sta->llid;
945 reason = sta->reason;
Johannes Berg07346f812008-05-03 01:02:02 +0200946 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700947 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
948 sta->sta.addr, llid, plid, reason);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100949 break;
950 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200951 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100952 }
953 break;
954 default:
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800955 /* should not get here, PLINK_BLOCKED is dealt with at the
Daniel Mack3ad2f3f2010-02-03 08:01:28 +0800956 * beginning of the function
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100957 */
Johannes Berg07346f812008-05-03 01:02:02 +0200958 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100959 break;
960 }
Johannes Bergd0709a62008-02-25 16:27:46 +0100961
962 rcu_read_unlock();
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700963
964 if (changed)
965 ieee80211_bss_info_change_notify(sdata, changed);
Luis Carlos Coboc3896d22008-02-23 15:17:13 +0100966}