Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 1 | /* |
Rui Paulo | 264d9b7 | 2009-11-09 23:46:58 +0000 | [diff] [blame] | 2 | * Copyright (c) 2008, 2009 open80211s Ltd. |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 3 | * 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 Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 9 | #include <linux/gfp.h> |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 10 | #include <linux/kernel.h> |
| 11 | #include <linux/random.h> |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 12 | #include "ieee80211_i.h" |
Johannes Berg | 2c8dccc | 2008-04-08 15:14:40 -0400 | [diff] [blame] | 13 | #include "rate.h" |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 14 | #include "mesh.h" |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 15 | |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 16 | #define PLINK_GET_LLID(p) (p + 2) |
| 17 | #define PLINK_GET_PLID(p) (p + 4) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 18 | |
| 19 | #define mod_plink_timer(s, t) (mod_timer(&s->plink_timer, \ |
| 20 | jiffies + HZ * t / 1000)) |
| 21 | |
Ashok Nagarajan | 3d4f9699 | 2012-03-06 12:48:30 -0800 | [diff] [blame] | 22 | /* We only need a valid sta if user configured a minimum rssi_threshold. */ |
| 23 | #define rssi_threshold_check(sta, sdata) \ |
Ashok Nagarajan | 5533513 | 2012-02-28 17:04:08 -0800 | [diff] [blame] | 24 | (sdata->u.mesh.mshcfg.rssi_threshold == 0 ||\ |
Ashok Nagarajan | 3d4f9699 | 2012-03-06 12:48:30 -0800 | [diff] [blame] | 25 | (sta && (s8) -ewma_read(&sta->avg_signal) > \ |
| 26 | sdata->u.mesh.mshcfg.rssi_threshold)) |
Ashok Nagarajan | 5533513 | 2012-02-28 17:04:08 -0800 | [diff] [blame] | 27 | |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 28 | enum 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 Pedersen | ba4a14e | 2011-09-20 13:43:32 -0700 | [diff] [blame] | 40 | static 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 Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 44 | /** |
| 45 | * mesh_plink_fsm_restart - restart a mesh peer link finite state machine |
| 46 | * |
Rui Paulo | 23c7a29 | 2009-11-09 23:46:42 +0000 | [diff] [blame] | 47 | * @sta: mesh peer link to restart |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 48 | * |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 49 | * Locking: this function must be called holding sta->lock |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 50 | */ |
| 51 | static inline void mesh_plink_fsm_restart(struct sta_info *sta) |
| 52 | { |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 53 | sta->plink_state = NL80211_PLINK_LISTEN; |
Luis Carlos Cobo | 37659ff | 2008-02-29 12:13:38 -0800 | [diff] [blame] | 54 | sta->llid = sta->plid = sta->reason = 0; |
| 55 | sta->plink_retries = 0; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 56 | } |
| 57 | |
Ben Hutchings | 2c53040 | 2012-07-10 10:55:09 +0000 | [diff] [blame] | 58 | /** |
Ashok Nagarajan | cbf9322 | 2012-05-07 21:00:31 -0700 | [diff] [blame] | 59 | * mesh_set_ht_prot_mode - set correct HT protection mode |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 60 | * |
Ashok Nagarajan | cbf9322 | 2012-05-07 21:00:31 -0700 | [diff] [blame] | 61 | * Section 9.23.3.5 of IEEE 80211-2012 describes the protection rules for HT |
| 62 | * mesh STA in a MBSS. Three HT protection modes are supported for now, non-HT |
| 63 | * mixed mode, 20MHz-protection and no-protection mode. non-HT mixed mode is |
| 64 | * selected if any non-HT peers are present in our MBSS. 20MHz-protection mode |
| 65 | * is selected if all peers in our 20/40MHz MBSS support HT and atleast one |
| 66 | * HT20 peer is present. Otherwise no-protection mode is selected. |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 67 | */ |
| 68 | static u32 mesh_set_ht_prot_mode(struct ieee80211_sub_if_data *sdata) |
| 69 | { |
| 70 | struct ieee80211_local *local = sdata->local; |
| 71 | struct sta_info *sta; |
| 72 | u32 changed = 0; |
| 73 | u16 ht_opmode; |
| 74 | bool non_ht_sta = false, ht20_sta = false; |
| 75 | |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 76 | if (sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT) |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 77 | return 0; |
| 78 | |
| 79 | rcu_read_lock(); |
| 80 | list_for_each_entry_rcu(sta, &local->sta_list, list) { |
Ashok Nagarajan | cbf9322 | 2012-05-07 21:00:31 -0700 | [diff] [blame] | 81 | if (sdata != sta->sdata || |
| 82 | sta->plink_state != NL80211_PLINK_ESTAB) |
| 83 | continue; |
| 84 | |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 85 | switch (sta->ch_width) { |
| 86 | case NL80211_CHAN_WIDTH_20_NOHT: |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 87 | mpl_dbg(sdata, |
| 88 | "mesh_plink %pM: nonHT sta (%pM) is present\n", |
Ashok Nagarajan | cbf9322 | 2012-05-07 21:00:31 -0700 | [diff] [blame] | 89 | sdata->vif.addr, sta->sta.addr); |
| 90 | non_ht_sta = true; |
| 91 | goto out; |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 92 | case NL80211_CHAN_WIDTH_20: |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 93 | mpl_dbg(sdata, |
| 94 | "mesh_plink %pM: HT20 sta (%pM) is present\n", |
Ashok Nagarajan | cbf9322 | 2012-05-07 21:00:31 -0700 | [diff] [blame] | 95 | sdata->vif.addr, sta->sta.addr); |
| 96 | ht20_sta = true; |
| 97 | default: |
| 98 | break; |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 99 | } |
| 100 | } |
| 101 | out: |
| 102 | rcu_read_unlock(); |
| 103 | |
| 104 | if (non_ht_sta) |
| 105 | ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED; |
Johannes Berg | 466f310 | 2012-07-25 13:51:49 +0200 | [diff] [blame] | 106 | else if (ht20_sta && |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 107 | sdata->vif.bss_conf.chandef.width > NL80211_CHAN_WIDTH_20) |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 108 | ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_20MHZ; |
| 109 | else |
| 110 | ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONE; |
| 111 | |
| 112 | if (sdata->vif.bss_conf.ht_operation_mode != ht_opmode) { |
| 113 | sdata->vif.bss_conf.ht_operation_mode = ht_opmode; |
Ashok Nagarajan | 70c33ea | 2012-04-30 14:20:32 -0700 | [diff] [blame] | 114 | sdata->u.mesh.mshcfg.ht_opmode = ht_opmode; |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 115 | changed = BSS_CHANGED_HT; |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 116 | mpl_dbg(sdata, |
| 117 | "mesh_plink %pM: protection mode changed to %d\n", |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 118 | sdata->vif.addr, ht_opmode); |
| 119 | } |
| 120 | |
| 121 | return changed; |
| 122 | } |
| 123 | |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 124 | /** |
John W. Linville | c937019 | 2010-06-21 17:14:07 -0400 | [diff] [blame] | 125 | * __mesh_plink_deactivate - deactivate mesh peer link |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 126 | * |
| 127 | * @sta: mesh peer link to deactivate |
| 128 | * |
| 129 | * All mesh paths with this peer as next hop will be flushed |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 130 | * Returns beacon changed flag if the beacon content changed. |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 131 | * |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 132 | * Locking: the caller must hold sta->lock |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 133 | */ |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 134 | static u32 __mesh_plink_deactivate(struct sta_info *sta) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 135 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 136 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 137 | u32 changed = 0; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 138 | |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 139 | if (sta->plink_state == NL80211_PLINK_ESTAB) |
| 140 | changed = mesh_plink_dec_estab_count(sdata); |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 141 | sta->plink_state = NL80211_PLINK_BLOCKED; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 142 | mesh_path_flush_by_nexthop(sta); |
John W. Linville | c937019 | 2010-06-21 17:14:07 -0400 | [diff] [blame] | 143 | |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 144 | return changed; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 145 | } |
| 146 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 147 | /** |
John W. Linville | c937019 | 2010-06-21 17:14:07 -0400 | [diff] [blame] | 148 | * mesh_plink_deactivate - deactivate mesh peer link |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 149 | * |
| 150 | * @sta: mesh peer link to deactivate |
| 151 | * |
| 152 | * All mesh paths with this peer as next hop will be flushed |
| 153 | */ |
| 154 | void mesh_plink_deactivate(struct sta_info *sta) |
| 155 | { |
John W. Linville | c937019 | 2010-06-21 17:14:07 -0400 | [diff] [blame] | 156 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 157 | u32 changed; |
John W. Linville | c937019 | 2010-06-21 17:14:07 -0400 | [diff] [blame] | 158 | |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 159 | spin_lock_bh(&sta->lock); |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 160 | changed = __mesh_plink_deactivate(sta); |
Thomas Pedersen | ba4a14e | 2011-09-20 13:43:32 -0700 | [diff] [blame] | 161 | sta->reason = cpu_to_le16(WLAN_REASON_MESH_PEER_CANCELED); |
| 162 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, |
| 163 | sta->sta.addr, sta->llid, sta->plid, |
| 164 | sta->reason); |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 165 | spin_unlock_bh(&sta->lock); |
John W. Linville | c937019 | 2010-06-21 17:14:07 -0400 | [diff] [blame] | 166 | |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 167 | ieee80211_bss_info_change_notify(sdata, changed); |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 168 | } |
| 169 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 170 | static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 171 | enum ieee80211_self_protected_actioncode action, |
| 172 | u8 *da, __le16 llid, __le16 plid, __le16 reason) { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 173 | struct ieee80211_local *local = sdata->local; |
Thomas Pedersen | 3b69a9c | 2011-10-26 14:47:25 -0700 | [diff] [blame] | 174 | struct sk_buff *skb; |
Thomas Pedersen | e7570df | 2012-08-03 12:21:34 -0700 | [diff] [blame] | 175 | struct ieee80211_tx_info *info; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 176 | struct ieee80211_mgmt *mgmt; |
| 177 | bool include_plid = false; |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 178 | u16 peering_proto = 0; |
Thomas Pedersen | 3b69a9c | 2011-10-26 14:47:25 -0700 | [diff] [blame] | 179 | u8 *pos, ie_len = 4; |
| 180 | int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.self_prot) + |
| 181 | sizeof(mgmt->u.action.u.self_prot); |
Thomas Pedersen | f609a43 | 2012-08-03 12:21:35 -0700 | [diff] [blame] | 182 | int err = -ENOMEM; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 183 | |
Javier Cardona | 65e8b0c | 2012-01-17 18:17:46 -0800 | [diff] [blame] | 184 | skb = dev_alloc_skb(local->tx_headroom + |
Thomas Pedersen | 3b69a9c | 2011-10-26 14:47:25 -0700 | [diff] [blame] | 185 | hdr_len + |
| 186 | 2 + /* capability info */ |
| 187 | 2 + /* AID */ |
| 188 | 2 + 8 + /* supported rates */ |
| 189 | 2 + (IEEE80211_MAX_SUPP_RATES - 8) + |
| 190 | 2 + sdata->u.mesh.mesh_id_len + |
| 191 | 2 + sizeof(struct ieee80211_meshconf_ie) + |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 192 | 2 + sizeof(struct ieee80211_ht_cap) + |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 193 | 2 + sizeof(struct ieee80211_ht_operation) + |
Thomas Pedersen | 3b69a9c | 2011-10-26 14:47:25 -0700 | [diff] [blame] | 194 | 2 + 8 + /* peering IE */ |
| 195 | sdata->u.mesh.ie_len); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 196 | if (!skb) |
| 197 | return -1; |
Thomas Pedersen | e7570df | 2012-08-03 12:21:34 -0700 | [diff] [blame] | 198 | info = IEEE80211_SKB_CB(skb); |
Javier Cardona | 65e8b0c | 2012-01-17 18:17:46 -0800 | [diff] [blame] | 199 | skb_reserve(skb, local->tx_headroom); |
Thomas Pedersen | 3b69a9c | 2011-10-26 14:47:25 -0700 | [diff] [blame] | 200 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len); |
| 201 | memset(mgmt, 0, hdr_len); |
Harvey Harrison | e7827a7 | 2008-07-15 18:44:13 -0700 | [diff] [blame] | 202 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 203 | IEEE80211_STYPE_ACTION); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 204 | memcpy(mgmt->da, da, ETH_ALEN); |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 205 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
Javier Cardona | 915b5c5 | 2011-05-03 16:57:10 -0700 | [diff] [blame] | 206 | memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 207 | mgmt->u.action.category = WLAN_CATEGORY_SELF_PROTECTED; |
| 208 | mgmt->u.action.u.self_prot.action_code = action; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 209 | |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 210 | if (action != WLAN_SP_MESH_PEERING_CLOSE) { |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 211 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
| 212 | |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 213 | /* capability info */ |
| 214 | pos = skb_put(skb, 2); |
| 215 | memset(pos, 0, 2); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 216 | if (action == WLAN_SP_MESH_PEERING_CONFIRM) { |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 217 | /* AID */ |
| 218 | pos = skb_put(skb, 2); |
Rui Paulo | 77fa76b | 2009-11-09 23:46:52 +0000 | [diff] [blame] | 219 | memcpy(pos + 2, &plid, 2); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 220 | } |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 221 | if (ieee80211_add_srates_ie(sdata, skb, true, band) || |
| 222 | ieee80211_add_ext_srates_ie(sdata, skb, true, band) || |
Thomas Pedersen | 082ebb0 | 2011-08-11 19:35:10 -0700 | [diff] [blame] | 223 | mesh_add_rsn_ie(skb, sdata) || |
| 224 | mesh_add_meshid_ie(skb, sdata) || |
| 225 | mesh_add_meshconf_ie(skb, sdata)) |
Thomas Pedersen | f609a43 | 2012-08-03 12:21:35 -0700 | [diff] [blame] | 226 | goto free; |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 227 | } else { /* WLAN_SP_MESH_PEERING_CLOSE */ |
Thomas Pedersen | e7570df | 2012-08-03 12:21:34 -0700 | [diff] [blame] | 228 | info->flags |= IEEE80211_TX_CTL_NO_ACK; |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 229 | if (mesh_add_meshid_ie(skb, sdata)) |
Thomas Pedersen | f609a43 | 2012-08-03 12:21:35 -0700 | [diff] [blame] | 230 | goto free; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 231 | } |
| 232 | |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 233 | /* Add Mesh Peering Management element */ |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 234 | switch (action) { |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 235 | case WLAN_SP_MESH_PEERING_OPEN: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 236 | break; |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 237 | case WLAN_SP_MESH_PEERING_CONFIRM: |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 238 | ie_len += 2; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 239 | include_plid = true; |
| 240 | break; |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 241 | case WLAN_SP_MESH_PEERING_CLOSE: |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 242 | if (plid) { |
| 243 | ie_len += 2; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 244 | include_plid = true; |
| 245 | } |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 246 | ie_len += 2; /* reason code */ |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 247 | break; |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 248 | default: |
Thomas Pedersen | f609a43 | 2012-08-03 12:21:35 -0700 | [diff] [blame] | 249 | err = -EINVAL; |
| 250 | goto free; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 251 | } |
| 252 | |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 253 | if (WARN_ON(skb_tailroom(skb) < 2 + ie_len)) |
Thomas Pedersen | f609a43 | 2012-08-03 12:21:35 -0700 | [diff] [blame] | 254 | goto free; |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 255 | |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 256 | pos = skb_put(skb, 2 + ie_len); |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 257 | *pos++ = WLAN_EID_PEER_MGMT; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 258 | *pos++ = ie_len; |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 259 | memcpy(pos, &peering_proto, 2); |
| 260 | pos += 2; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 261 | memcpy(pos, &llid, 2); |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 262 | pos += 2; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 263 | if (include_plid) { |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 264 | memcpy(pos, &plid, 2); |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 265 | pos += 2; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 266 | } |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 267 | if (action == WLAN_SP_MESH_PEERING_CLOSE) { |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 268 | memcpy(pos, &reason, 2); |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 269 | pos += 2; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 270 | } |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 271 | |
| 272 | if (action != WLAN_SP_MESH_PEERING_CLOSE) { |
| 273 | if (mesh_add_ht_cap_ie(skb, sdata) || |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 274 | mesh_add_ht_oper_ie(skb, sdata)) |
Thomas Pedersen | f609a43 | 2012-08-03 12:21:35 -0700 | [diff] [blame] | 275 | goto free; |
Thomas Pedersen | 176f360 | 2011-10-26 14:47:27 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 278 | if (mesh_add_vendor_ies(skb, sdata)) |
Thomas Pedersen | f609a43 | 2012-08-03 12:21:35 -0700 | [diff] [blame] | 279 | goto free; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 280 | |
Johannes Berg | 62ae67b | 2009-11-18 18:42:05 +0100 | [diff] [blame] | 281 | ieee80211_tx_skb(sdata, skb); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 282 | return 0; |
Thomas Pedersen | f609a43 | 2012-08-03 12:21:35 -0700 | [diff] [blame] | 283 | free: |
| 284 | kfree_skb(skb); |
| 285 | return err; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 286 | } |
| 287 | |
Thomas Pedersen | 296fcba3 | 2013-01-23 12:18:12 -0800 | [diff] [blame^] | 288 | static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata, |
| 289 | struct sta_info *sta, |
| 290 | struct ieee802_11_elems *elems, bool insert) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 291 | { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 292 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 293 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 294 | struct ieee80211_supported_band *sband; |
Thomas Pedersen | f743ff4 | 2012-04-18 19:23:43 -0700 | [diff] [blame] | 295 | u32 rates, basic_rates = 0; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 296 | |
Thomas Pedersen | f743ff4 | 2012-04-18 19:23:43 -0700 | [diff] [blame] | 297 | sband = local->hw.wiphy->bands[band]; |
| 298 | rates = ieee80211_sta_get_rates(local, elems, band, &basic_rates); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 299 | |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 300 | spin_lock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 301 | sta->last_rx = jiffies; |
Thomas Pedersen | 296fcba3 | 2013-01-23 12:18:12 -0800 | [diff] [blame^] | 302 | |
| 303 | /* rates and capabilities don't change during peering */ |
| 304 | if (sta->plink_state == NL80211_PLINK_ESTAB) |
| 305 | goto out; |
Chun-Yeow Yeoh | bae35d9 | 2012-07-24 11:52:35 +0800 | [diff] [blame] | 306 | |
Thomas Pedersen | f743ff4 | 2012-04-18 19:23:43 -0700 | [diff] [blame] | 307 | sta->sta.supp_rates[band] = rates; |
Thomas Pedersen | e76781e | 2012-04-18 19:24:13 -0700 | [diff] [blame] | 308 | if (elems->ht_cap_elem && |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 309 | sdata->vif.bss_conf.chandef.width != NL80211_CHAN_WIDTH_20_NOHT) |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 310 | ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, |
| 311 | elems->ht_cap_elem, |
| 312 | &sta->sta.ht_cap); |
| 313 | else |
| 314 | memset(&sta->sta.ht_cap, 0, sizeof(sta->sta.ht_cap)); |
| 315 | |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 316 | if (elems->ht_operation) { |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 317 | struct cfg80211_chan_def chandef; |
| 318 | |
Thomas Pedersen | c7d2582 | 2012-04-26 15:01:07 -0700 | [diff] [blame] | 319 | if (!(elems->ht_operation->ht_param & |
| 320 | IEEE80211_HT_PARAM_CHAN_WIDTH_ANY)) |
| 321 | sta->sta.ht_cap.cap &= |
| 322 | ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 323 | ieee80211_ht_oper_to_chandef(sdata->vif.bss_conf.chandef.chan, |
| 324 | elems->ht_operation, &chandef); |
| 325 | sta->ch_width = chandef.width; |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 326 | } |
Thomas Pedersen | c7d2582 | 2012-04-26 15:01:07 -0700 | [diff] [blame] | 327 | |
Helmut Schaa | 59cf1d6 | 2012-11-27 18:03:13 +0100 | [diff] [blame] | 328 | if (insert) |
| 329 | rate_control_rate_init(sta); |
Thomas Pedersen | 296fcba3 | 2013-01-23 12:18:12 -0800 | [diff] [blame^] | 330 | out: |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 331 | spin_unlock_bh(&sta->lock); |
Thomas Pedersen | 296fcba3 | 2013-01-23 12:18:12 -0800 | [diff] [blame^] | 332 | } |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 333 | |
Thomas Pedersen | 296fcba3 | 2013-01-23 12:18:12 -0800 | [diff] [blame^] | 334 | static struct sta_info * |
| 335 | __mesh_sta_info_alloc(struct ieee80211_sub_if_data *sdata, u8 *hw_addr) |
| 336 | { |
| 337 | struct sta_info *sta; |
| 338 | |
| 339 | if (sdata->local->num_sta >= MESH_MAX_PLINKS) |
Thomas Pedersen | e87278e | 2012-04-26 15:01:06 -0700 | [diff] [blame] | 340 | return NULL; |
| 341 | |
Thomas Pedersen | 296fcba3 | 2013-01-23 12:18:12 -0800 | [diff] [blame^] | 342 | sta = sta_info_alloc(sdata, hw_addr, GFP_KERNEL); |
| 343 | if (!sta) |
| 344 | return NULL; |
| 345 | |
| 346 | sta->plink_state = NL80211_PLINK_LISTEN; |
| 347 | init_timer(&sta->plink_timer); |
| 348 | |
| 349 | sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); |
| 350 | sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); |
| 351 | sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED); |
| 352 | |
| 353 | set_sta_flag(sta, WLAN_STA_WME); |
| 354 | |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 355 | return sta; |
| 356 | } |
| 357 | |
Thomas Pedersen | 296fcba3 | 2013-01-23 12:18:12 -0800 | [diff] [blame^] | 358 | static struct sta_info * |
| 359 | mesh_sta_info_alloc(struct ieee80211_sub_if_data *sdata, u8 *addr, |
| 360 | struct ieee802_11_elems *elems) |
| 361 | { |
| 362 | struct sta_info *sta = NULL; |
| 363 | |
| 364 | /* Userspace handles peer allocation when security is enabled */ |
| 365 | if (sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED) |
| 366 | cfg80211_notify_new_peer_candidate(sdata->dev, addr, |
| 367 | elems->ie_start, |
| 368 | elems->total_len, |
| 369 | GFP_KERNEL); |
| 370 | else |
| 371 | sta = __mesh_sta_info_alloc(sdata, addr); |
| 372 | |
| 373 | return sta; |
| 374 | } |
| 375 | |
| 376 | /* |
| 377 | * mesh_sta_info_get - return mesh sta info entry for @addr. |
| 378 | * |
| 379 | * @sdata: local meshif |
| 380 | * @addr: peer's address |
| 381 | * @elems: IEs from beacon or mesh peering frame. |
| 382 | * |
| 383 | * Return existing or newly allocated sta_info under RCU read lock. |
| 384 | * (re)initialize with given IEs. |
| 385 | */ |
| 386 | static struct sta_info * |
| 387 | mesh_sta_info_get(struct ieee80211_sub_if_data *sdata, |
| 388 | u8 *addr, struct ieee802_11_elems *elems) __acquires(RCU) |
| 389 | { |
| 390 | struct sta_info *sta = NULL; |
| 391 | |
| 392 | rcu_read_lock(); |
| 393 | sta = sta_info_get(sdata, addr); |
| 394 | if (sta) { |
| 395 | mesh_sta_info_init(sdata, sta, elems, false); |
| 396 | } else { |
| 397 | rcu_read_unlock(); |
| 398 | /* can't run atomic */ |
| 399 | sta = mesh_sta_info_alloc(sdata, addr, elems); |
| 400 | if (!sta) { |
| 401 | rcu_read_lock(); |
| 402 | return NULL; |
| 403 | } |
| 404 | |
| 405 | if (sta_info_insert_rcu(sta)) |
| 406 | return NULL; |
| 407 | } |
| 408 | |
| 409 | return sta; |
| 410 | } |
| 411 | |
| 412 | /* |
| 413 | * mesh_neighbour_update - update or initialize new mesh neighbor. |
| 414 | * |
| 415 | * @sdata: local meshif |
| 416 | * @addr: peer's address |
| 417 | * @elems: IEs from beacon or mesh peering frame |
| 418 | * |
| 419 | * Initiates peering if appropriate. |
| 420 | */ |
Thomas Pedersen | f743ff4 | 2012-04-18 19:23:43 -0700 | [diff] [blame] | 421 | void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata, |
| 422 | u8 *hw_addr, |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 423 | struct ieee802_11_elems *elems) |
| 424 | { |
| 425 | struct sta_info *sta; |
| 426 | |
Thomas Pedersen | 296fcba3 | 2013-01-23 12:18:12 -0800 | [diff] [blame^] | 427 | sta = mesh_sta_info_get(sdata, hw_addr, elems); |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 428 | if (!sta) |
| 429 | goto out; |
| 430 | |
Javier Cardona | 1570ca5 | 2011-04-07 15:08:35 -0700 | [diff] [blame] | 431 | if (mesh_peer_accepts_plinks(elems) && |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 432 | sta->plink_state == NL80211_PLINK_LISTEN && |
| 433 | sdata->u.mesh.accepting_plinks && |
| 434 | sdata->u.mesh.mshcfg.auto_open_plinks && |
| 435 | rssi_threshold_check(sta, sdata)) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 436 | mesh_plink_open(sta); |
| 437 | |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 438 | out: |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 439 | rcu_read_unlock(); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | static void mesh_plink_timer(unsigned long data) |
| 443 | { |
| 444 | struct sta_info *sta; |
| 445 | __le16 llid, plid, reason; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 446 | struct ieee80211_sub_if_data *sdata; |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 447 | struct mesh_config *mshcfg; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 448 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 449 | /* |
| 450 | * This STA is valid because sta_info_destroy() will |
| 451 | * del_timer_sync() this timer after having made sure |
| 452 | * it cannot be readded (by deleting the plink.) |
| 453 | */ |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 454 | sta = (struct sta_info *) data; |
| 455 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 456 | if (sta->sdata->local->quiescing) { |
| 457 | sta->plink_timer_was_running = true; |
| 458 | return; |
| 459 | } |
| 460 | |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 461 | spin_lock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 462 | if (sta->ignore_plink_timer) { |
| 463 | sta->ignore_plink_timer = false; |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 464 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 465 | return; |
| 466 | } |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 467 | mpl_dbg(sta->sdata, |
| 468 | "Mesh plink timer for %pM fired on state %d\n", |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 469 | sta->sta.addr, sta->plink_state); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 470 | reason = 0; |
| 471 | llid = sta->llid; |
| 472 | plid = sta->plid; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 473 | sdata = sta->sdata; |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 474 | mshcfg = &sdata->u.mesh.mshcfg; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 475 | |
| 476 | switch (sta->plink_state) { |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 477 | case NL80211_PLINK_OPN_RCVD: |
| 478 | case NL80211_PLINK_OPN_SNT: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 479 | /* retry timer */ |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 480 | if (sta->plink_retries < mshcfg->dot11MeshMaxRetries) { |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 481 | u32 rand; |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 482 | mpl_dbg(sta->sdata, |
| 483 | "Mesh plink for %pM (retry, timeout): %d %d\n", |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 484 | sta->sta.addr, sta->plink_retries, |
| 485 | sta->plink_timeout); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 486 | get_random_bytes(&rand, sizeof(u32)); |
| 487 | sta->plink_timeout = sta->plink_timeout + |
| 488 | rand % sta->plink_timeout; |
| 489 | ++sta->plink_retries; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 490 | mod_plink_timer(sta, sta->plink_timeout); |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 491 | spin_unlock_bh(&sta->lock); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 492 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_OPEN, |
| 493 | sta->sta.addr, llid, 0, 0); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 494 | break; |
| 495 | } |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 496 | reason = cpu_to_le16(WLAN_REASON_MESH_MAX_RETRIES); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 497 | /* fall through on else */ |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 498 | case NL80211_PLINK_CNF_RCVD: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 499 | /* confirm timer */ |
| 500 | if (!reason) |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 501 | reason = cpu_to_le16(WLAN_REASON_MESH_CONFIRM_TIMEOUT); |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 502 | sta->plink_state = NL80211_PLINK_HOLDING; |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 503 | mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 504 | spin_unlock_bh(&sta->lock); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 505 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, |
| 506 | sta->sta.addr, llid, plid, reason); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 507 | break; |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 508 | case NL80211_PLINK_HOLDING: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 509 | /* holding timer */ |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 510 | del_timer(&sta->plink_timer); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 511 | mesh_plink_fsm_restart(sta); |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 512 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 513 | break; |
| 514 | default: |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 515 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 516 | break; |
| 517 | } |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 518 | } |
| 519 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 520 | #ifdef CONFIG_PM |
| 521 | void mesh_plink_quiesce(struct sta_info *sta) |
| 522 | { |
| 523 | if (del_timer_sync(&sta->plink_timer)) |
| 524 | sta->plink_timer_was_running = true; |
| 525 | } |
| 526 | |
| 527 | void mesh_plink_restart(struct sta_info *sta) |
| 528 | { |
| 529 | if (sta->plink_timer_was_running) { |
| 530 | add_timer(&sta->plink_timer); |
| 531 | sta->plink_timer_was_running = false; |
| 532 | } |
| 533 | } |
| 534 | #endif |
| 535 | |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 536 | static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout) |
| 537 | { |
| 538 | sta->plink_timer.expires = jiffies + (HZ * timeout / 1000); |
| 539 | sta->plink_timer.data = (unsigned long) sta; |
| 540 | sta->plink_timer.function = mesh_plink_timer; |
| 541 | sta->plink_timeout = timeout; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 542 | add_timer(&sta->plink_timer); |
| 543 | } |
| 544 | |
| 545 | int mesh_plink_open(struct sta_info *sta) |
| 546 | { |
| 547 | __le16 llid; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 548 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 549 | |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 550 | if (!test_sta_flag(sta, WLAN_STA_AUTH)) |
Javier Cardona | 53e8051 | 2011-04-07 15:08:32 -0700 | [diff] [blame] | 551 | return -EPERM; |
| 552 | |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 553 | spin_lock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 554 | get_random_bytes(&llid, 2); |
| 555 | sta->llid = llid; |
Chun-Yeow Yeoh | 9385d04 | 2012-09-14 14:18:31 +0800 | [diff] [blame] | 556 | if (sta->plink_state != NL80211_PLINK_LISTEN && |
| 557 | sta->plink_state != NL80211_PLINK_BLOCKED) { |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 558 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 559 | return -EBUSY; |
| 560 | } |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 561 | sta->plink_state = NL80211_PLINK_OPN_SNT; |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 562 | mesh_plink_timer_set(sta, sdata->u.mesh.mshcfg.dot11MeshRetryTimeout); |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 563 | spin_unlock_bh(&sta->lock); |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 564 | mpl_dbg(sdata, |
| 565 | "Mesh plink: starting establishment with %pM\n", |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 566 | sta->sta.addr); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 567 | |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 568 | return mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_OPEN, |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 569 | sta->sta.addr, llid, 0, 0); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | void mesh_plink_block(struct sta_info *sta) |
| 573 | { |
John W. Linville | c937019 | 2010-06-21 17:14:07 -0400 | [diff] [blame] | 574 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 575 | u32 changed; |
John W. Linville | c937019 | 2010-06-21 17:14:07 -0400 | [diff] [blame] | 576 | |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 577 | spin_lock_bh(&sta->lock); |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 578 | changed = __mesh_plink_deactivate(sta); |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 579 | sta->plink_state = NL80211_PLINK_BLOCKED; |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 580 | spin_unlock_bh(&sta->lock); |
John W. Linville | c937019 | 2010-06-21 17:14:07 -0400 | [diff] [blame] | 581 | |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 582 | ieee80211_bss_info_change_notify(sdata, changed); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 583 | } |
| 584 | |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 585 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 586 | void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt, |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 587 | size_t len, struct ieee80211_rx_status *rx_status) |
| 588 | { |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 589 | struct mesh_config *mshcfg = &sdata->u.mesh.mshcfg; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 590 | struct ieee802_11_elems elems; |
| 591 | struct sta_info *sta; |
| 592 | enum plink_event event; |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 593 | enum ieee80211_self_protected_actioncode ftype; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 594 | size_t baselen; |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 595 | bool matches_local = true; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 596 | u8 ie_len; |
| 597 | u8 *baseaddr; |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 598 | u32 changed = 0; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 599 | __le16 plid, llid, reason; |
Rui Paulo | 1460dd1 | 2009-11-09 23:46:48 +0000 | [diff] [blame] | 600 | static const char *mplstates[] = { |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 601 | [NL80211_PLINK_LISTEN] = "LISTEN", |
| 602 | [NL80211_PLINK_OPN_SNT] = "OPN-SNT", |
| 603 | [NL80211_PLINK_OPN_RCVD] = "OPN-RCVD", |
| 604 | [NL80211_PLINK_CNF_RCVD] = "CNF_RCVD", |
| 605 | [NL80211_PLINK_ESTAB] = "ESTAB", |
| 606 | [NL80211_PLINK_HOLDING] = "HOLDING", |
| 607 | [NL80211_PLINK_BLOCKED] = "BLOCKED" |
Rui Paulo | 1460dd1 | 2009-11-09 23:46:48 +0000 | [diff] [blame] | 608 | }; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 609 | |
Johannes Berg | 9c80d3d | 2008-09-08 15:41:59 +0200 | [diff] [blame] | 610 | /* need action_code, aux */ |
| 611 | if (len < IEEE80211_MIN_ACTION_SIZE + 3) |
| 612 | return; |
| 613 | |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 614 | if (is_multicast_ether_addr(mgmt->da)) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 615 | mpl_dbg(sdata, |
| 616 | "Mesh plink: ignore frame from multicast address\n"); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 617 | return; |
| 618 | } |
| 619 | |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 620 | baseaddr = mgmt->u.action.u.self_prot.variable; |
| 621 | baselen = (u8 *) mgmt->u.action.u.self_prot.variable - (u8 *) mgmt; |
| 622 | if (mgmt->u.action.u.self_prot.action_code == |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 623 | WLAN_SP_MESH_PEERING_CONFIRM) { |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 624 | baseaddr += 4; |
David Woo | 70bdb6b | 2009-08-12 11:03:44 -0700 | [diff] [blame] | 625 | baselen += 4; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 626 | } |
| 627 | ieee802_11_parse_elems(baseaddr, len - baselen, &elems); |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 628 | if (!elems.peering) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 629 | mpl_dbg(sdata, |
| 630 | "Mesh plink: missing necessary peer link ie\n"); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 631 | return; |
| 632 | } |
Javier Cardona | b130e5c | 2011-05-03 16:57:07 -0700 | [diff] [blame] | 633 | if (elems.rsn_len && |
| 634 | sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 635 | mpl_dbg(sdata, |
| 636 | "Mesh plink: can't establish link with secure peer\n"); |
Javier Cardona | 5cff5e0 | 2011-04-07 15:08:29 -0700 | [diff] [blame] | 637 | return; |
| 638 | } |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 639 | |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 640 | ftype = mgmt->u.action.u.self_prot.action_code; |
| 641 | ie_len = elems.peering_len; |
| 642 | if ((ftype == WLAN_SP_MESH_PEERING_OPEN && ie_len != 4) || |
| 643 | (ftype == WLAN_SP_MESH_PEERING_CONFIRM && ie_len != 6) || |
| 644 | (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len != 6 |
| 645 | && ie_len != 8)) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 646 | mpl_dbg(sdata, |
| 647 | "Mesh plink: incorrect plink ie length %d %d\n", |
| 648 | ftype, ie_len); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 649 | return; |
| 650 | } |
| 651 | |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 652 | if (ftype != WLAN_SP_MESH_PEERING_CLOSE && |
| 653 | (!elems.mesh_id || !elems.mesh_config)) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 654 | mpl_dbg(sdata, "Mesh plink: missing necessary ie\n"); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 655 | return; |
| 656 | } |
| 657 | /* Note the lines below are correct, the llid in the frame is the plid |
| 658 | * from the point of view of this host. |
| 659 | */ |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 660 | memcpy(&plid, PLINK_GET_LLID(elems.peering), 2); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 661 | if (ftype == WLAN_SP_MESH_PEERING_CONFIRM || |
Thomas Pedersen | 8db0985 | 2011-08-12 20:01:00 -0700 | [diff] [blame] | 662 | (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len == 8)) |
| 663 | memcpy(&llid, PLINK_GET_PLID(elems.peering), 2); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 664 | |
Thomas Pedersen | 296fcba3 | 2013-01-23 12:18:12 -0800 | [diff] [blame^] | 665 | /* WARNING: Only for sta pointer, is dropped & re-acquired */ |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 666 | rcu_read_lock(); |
| 667 | |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 668 | sta = sta_info_get(sdata, mgmt->sa); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 669 | if (!sta && ftype != WLAN_SP_MESH_PEERING_OPEN) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 670 | mpl_dbg(sdata, "Mesh plink: cls or cnf from unknown peer\n"); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 671 | rcu_read_unlock(); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 672 | return; |
| 673 | } |
| 674 | |
Ashok Nagarajan | 5533513 | 2012-02-28 17:04:08 -0800 | [diff] [blame] | 675 | if (ftype == WLAN_SP_MESH_PEERING_OPEN && |
Ashok Nagarajan | 3d4f9699 | 2012-03-06 12:48:30 -0800 | [diff] [blame] | 676 | !rssi_threshold_check(sta, sdata)) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 677 | mpl_dbg(sdata, "Mesh plink: %pM does not meet rssi threshold\n", |
Ashok Nagarajan | 3d4f9699 | 2012-03-06 12:48:30 -0800 | [diff] [blame] | 678 | mgmt->sa); |
Ashok Nagarajan | 5533513 | 2012-02-28 17:04:08 -0800 | [diff] [blame] | 679 | rcu_read_unlock(); |
| 680 | return; |
| 681 | } |
| 682 | |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 683 | if (sta && !test_sta_flag(sta, WLAN_STA_AUTH)) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 684 | mpl_dbg(sdata, "Mesh plink: Action frame from non-authed peer\n"); |
Javier Cardona | 53e8051 | 2011-04-07 15:08:32 -0700 | [diff] [blame] | 685 | rcu_read_unlock(); |
| 686 | return; |
| 687 | } |
| 688 | |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 689 | if (sta && sta->plink_state == NL80211_PLINK_BLOCKED) { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 690 | rcu_read_unlock(); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 691 | return; |
| 692 | } |
| 693 | |
| 694 | /* Now we will figure out the appropriate event... */ |
| 695 | event = PLINK_UNDEFINED; |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 696 | if (ftype != WLAN_SP_MESH_PEERING_CLOSE && |
Thomas Pedersen | f743ff4 | 2012-04-18 19:23:43 -0700 | [diff] [blame] | 697 | !mesh_matches_local(sdata, &elems)) { |
Christian Lamparter | d12c745 | 2010-10-08 22:27:07 +0200 | [diff] [blame] | 698 | matches_local = false; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 699 | switch (ftype) { |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 700 | case WLAN_SP_MESH_PEERING_OPEN: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 701 | event = OPN_RJCT; |
| 702 | break; |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 703 | case WLAN_SP_MESH_PEERING_CONFIRM: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 704 | event = CNF_RJCT; |
| 705 | break; |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 706 | default: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 707 | break; |
| 708 | } |
Christian Lamparter | d12c745 | 2010-10-08 22:27:07 +0200 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | if (!sta && !matches_local) { |
| 712 | rcu_read_unlock(); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 713 | reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG); |
Christian Lamparter | d12c745 | 2010-10-08 22:27:07 +0200 | [diff] [blame] | 714 | llid = 0; |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 715 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, |
| 716 | mgmt->sa, llid, plid, reason); |
Christian Lamparter | d12c745 | 2010-10-08 22:27:07 +0200 | [diff] [blame] | 717 | return; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 718 | } else if (!sta) { |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 719 | /* ftype == WLAN_SP_MESH_PEERING_OPEN */ |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 720 | if (!mesh_plink_free_count(sdata)) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 721 | mpl_dbg(sdata, "Mesh plink error: no more free plinks\n"); |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 722 | rcu_read_unlock(); |
| 723 | return; |
| 724 | } |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 725 | event = OPN_ACPT; |
Christian Lamparter | d12c745 | 2010-10-08 22:27:07 +0200 | [diff] [blame] | 726 | } else if (matches_local) { |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 727 | switch (ftype) { |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 728 | case WLAN_SP_MESH_PEERING_OPEN: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 729 | if (!mesh_plink_free_count(sdata) || |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 730 | (sta->plid && sta->plid != plid)) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 731 | event = OPN_IGNR; |
| 732 | else |
| 733 | event = OPN_ACPT; |
| 734 | break; |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 735 | case WLAN_SP_MESH_PEERING_CONFIRM: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 736 | if (!mesh_plink_free_count(sdata) || |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 737 | (sta->llid != llid || sta->plid != plid)) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 738 | event = CNF_IGNR; |
| 739 | else |
| 740 | event = CNF_ACPT; |
| 741 | break; |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 742 | case WLAN_SP_MESH_PEERING_CLOSE: |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 743 | if (sta->plink_state == NL80211_PLINK_ESTAB) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 744 | /* Do not check for llid or plid. This does not |
| 745 | * follow the standard but since multiple plinks |
| 746 | * per sta are not supported, it is necessary in |
| 747 | * order to avoid a livelock when MP A sees an |
| 748 | * establish peer link to MP B but MP B does not |
| 749 | * see it. This can be caused by a timeout in |
| 750 | * B's peer link establishment or B beign |
| 751 | * restarted. |
| 752 | */ |
| 753 | event = CLS_ACPT; |
| 754 | else if (sta->plid != plid) |
| 755 | event = CLS_IGNR; |
| 756 | else if (ie_len == 7 && sta->llid != llid) |
| 757 | event = CLS_IGNR; |
| 758 | else |
| 759 | event = CLS_ACPT; |
| 760 | break; |
| 761 | default: |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 762 | mpl_dbg(sdata, "Mesh plink: unknown frame subtype\n"); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 763 | rcu_read_unlock(); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 764 | return; |
| 765 | } |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | if (event == OPN_ACPT) { |
Thomas Pedersen | 296fcba3 | 2013-01-23 12:18:12 -0800 | [diff] [blame^] | 769 | rcu_read_unlock(); |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 770 | /* allocate sta entry if necessary and update info */ |
Thomas Pedersen | 296fcba3 | 2013-01-23 12:18:12 -0800 | [diff] [blame^] | 771 | sta = mesh_sta_info_get(sdata, mgmt->sa, &elems); |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 772 | if (!sta) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 773 | mpl_dbg(sdata, "Mesh plink: failed to init peer!\n"); |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 774 | rcu_read_unlock(); |
| 775 | return; |
| 776 | } |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 777 | } |
| 778 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 779 | mpl_dbg(sdata, |
| 780 | "Mesh plink (peer, state, llid, plid, event): %pM %s %d %d %d\n", |
Rui Paulo | 1460dd1 | 2009-11-09 23:46:48 +0000 | [diff] [blame] | 781 | mgmt->sa, mplstates[sta->plink_state], |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 782 | le16_to_cpu(sta->llid), le16_to_cpu(sta->plid), |
| 783 | event); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 784 | reason = 0; |
Thomas Pedersen | 54ab1ff | 2012-04-18 19:23:42 -0700 | [diff] [blame] | 785 | spin_lock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 786 | switch (sta->plink_state) { |
| 787 | /* spin_unlock as soon as state is updated at each case */ |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 788 | case NL80211_PLINK_LISTEN: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 789 | switch (event) { |
| 790 | case CLS_ACPT: |
| 791 | mesh_plink_fsm_restart(sta); |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 792 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 793 | break; |
| 794 | case OPN_ACPT: |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 795 | sta->plink_state = NL80211_PLINK_OPN_RCVD; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 796 | sta->plid = plid; |
| 797 | get_random_bytes(&llid, 2); |
| 798 | sta->llid = llid; |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 799 | mesh_plink_timer_set(sta, |
| 800 | mshcfg->dot11MeshRetryTimeout); |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 801 | spin_unlock_bh(&sta->lock); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 802 | mesh_plink_frame_tx(sdata, |
| 803 | WLAN_SP_MESH_PEERING_OPEN, |
| 804 | sta->sta.addr, llid, 0, 0); |
| 805 | mesh_plink_frame_tx(sdata, |
| 806 | WLAN_SP_MESH_PEERING_CONFIRM, |
| 807 | sta->sta.addr, llid, plid, 0); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 808 | break; |
| 809 | default: |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 810 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 811 | break; |
| 812 | } |
| 813 | break; |
| 814 | |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 815 | case NL80211_PLINK_OPN_SNT: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 816 | switch (event) { |
| 817 | case OPN_RJCT: |
| 818 | case CNF_RJCT: |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 819 | reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 820 | case CLS_ACPT: |
| 821 | if (!reason) |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 822 | reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 823 | sta->reason = reason; |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 824 | sta->plink_state = NL80211_PLINK_HOLDING; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 825 | if (!mod_plink_timer(sta, |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 826 | mshcfg->dot11MeshHoldingTimeout)) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 827 | sta->ignore_plink_timer = true; |
| 828 | |
| 829 | llid = sta->llid; |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 830 | spin_unlock_bh(&sta->lock); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 831 | mesh_plink_frame_tx(sdata, |
| 832 | WLAN_SP_MESH_PEERING_CLOSE, |
| 833 | sta->sta.addr, llid, plid, reason); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 834 | break; |
| 835 | case OPN_ACPT: |
| 836 | /* retry timer is left untouched */ |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 837 | sta->plink_state = NL80211_PLINK_OPN_RCVD; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 838 | sta->plid = plid; |
| 839 | llid = sta->llid; |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 840 | spin_unlock_bh(&sta->lock); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 841 | mesh_plink_frame_tx(sdata, |
| 842 | WLAN_SP_MESH_PEERING_CONFIRM, |
| 843 | sta->sta.addr, llid, plid, 0); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 844 | break; |
| 845 | case CNF_ACPT: |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 846 | sta->plink_state = NL80211_PLINK_CNF_RCVD; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 847 | if (!mod_plink_timer(sta, |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 848 | mshcfg->dot11MeshConfirmTimeout)) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 849 | sta->ignore_plink_timer = true; |
| 850 | |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 851 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 852 | break; |
| 853 | default: |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 854 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 855 | break; |
| 856 | } |
| 857 | break; |
| 858 | |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 859 | case NL80211_PLINK_OPN_RCVD: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 860 | switch (event) { |
| 861 | case OPN_RJCT: |
| 862 | case CNF_RJCT: |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 863 | reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 864 | case CLS_ACPT: |
| 865 | if (!reason) |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 866 | reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 867 | sta->reason = reason; |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 868 | sta->plink_state = NL80211_PLINK_HOLDING; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 869 | if (!mod_plink_timer(sta, |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 870 | mshcfg->dot11MeshHoldingTimeout)) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 871 | sta->ignore_plink_timer = true; |
| 872 | |
| 873 | llid = sta->llid; |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 874 | spin_unlock_bh(&sta->lock); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 875 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, |
| 876 | sta->sta.addr, llid, plid, reason); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 877 | break; |
| 878 | case OPN_ACPT: |
| 879 | llid = sta->llid; |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 880 | spin_unlock_bh(&sta->lock); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 881 | mesh_plink_frame_tx(sdata, |
| 882 | WLAN_SP_MESH_PEERING_CONFIRM, |
| 883 | sta->sta.addr, llid, plid, 0); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 884 | break; |
| 885 | case CNF_ACPT: |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 886 | del_timer(&sta->plink_timer); |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 887 | sta->plink_state = NL80211_PLINK_ESTAB; |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 888 | spin_unlock_bh(&sta->lock); |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 889 | changed |= mesh_plink_inc_estab_count(sdata); |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 890 | changed |= mesh_set_ht_prot_mode(sdata); |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 891 | mpl_dbg(sdata, "Mesh plink with %pM ESTABLISHED\n", |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 892 | sta->sta.addr); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 893 | break; |
| 894 | default: |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 895 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 896 | break; |
| 897 | } |
| 898 | break; |
| 899 | |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 900 | case NL80211_PLINK_CNF_RCVD: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 901 | switch (event) { |
| 902 | case OPN_RJCT: |
| 903 | case CNF_RJCT: |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 904 | reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 905 | case CLS_ACPT: |
| 906 | if (!reason) |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 907 | reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 908 | sta->reason = reason; |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 909 | sta->plink_state = NL80211_PLINK_HOLDING; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 910 | if (!mod_plink_timer(sta, |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 911 | mshcfg->dot11MeshHoldingTimeout)) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 912 | sta->ignore_plink_timer = true; |
| 913 | |
| 914 | llid = sta->llid; |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 915 | spin_unlock_bh(&sta->lock); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 916 | mesh_plink_frame_tx(sdata, |
| 917 | WLAN_SP_MESH_PEERING_CLOSE, |
| 918 | sta->sta.addr, llid, plid, reason); |
Johannes Berg | ff59dc7 | 2008-02-25 10:11:50 +0100 | [diff] [blame] | 919 | break; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 920 | case OPN_ACPT: |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 921 | del_timer(&sta->plink_timer); |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 922 | sta->plink_state = NL80211_PLINK_ESTAB; |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 923 | spin_unlock_bh(&sta->lock); |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 924 | changed |= mesh_plink_inc_estab_count(sdata); |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 925 | changed |= mesh_set_ht_prot_mode(sdata); |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 926 | mpl_dbg(sdata, "Mesh plink with %pM ESTABLISHED\n", |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 927 | sta->sta.addr); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 928 | mesh_plink_frame_tx(sdata, |
| 929 | WLAN_SP_MESH_PEERING_CONFIRM, |
| 930 | sta->sta.addr, llid, plid, 0); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 931 | break; |
| 932 | default: |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 933 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 934 | break; |
| 935 | } |
| 936 | break; |
| 937 | |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 938 | case NL80211_PLINK_ESTAB: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 939 | switch (event) { |
| 940 | case CLS_ACPT: |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 941 | reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 942 | sta->reason = reason; |
Marco Porsch | df32381 | 2012-08-08 07:58:43 +0200 | [diff] [blame] | 943 | changed |= __mesh_plink_deactivate(sta); |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 944 | sta->plink_state = NL80211_PLINK_HOLDING; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 945 | llid = sta->llid; |
Marco Porsch | 453e66f | 2012-11-21 18:40:32 -0800 | [diff] [blame] | 946 | mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 947 | spin_unlock_bh(&sta->lock); |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 948 | changed |= mesh_set_ht_prot_mode(sdata); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 949 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, |
| 950 | sta->sta.addr, llid, plid, reason); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 951 | break; |
| 952 | case OPN_ACPT: |
| 953 | llid = sta->llid; |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 954 | spin_unlock_bh(&sta->lock); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 955 | mesh_plink_frame_tx(sdata, |
| 956 | WLAN_SP_MESH_PEERING_CONFIRM, |
| 957 | sta->sta.addr, llid, plid, 0); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 958 | break; |
| 959 | default: |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 960 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 961 | break; |
| 962 | } |
| 963 | break; |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 964 | case NL80211_PLINK_HOLDING: |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 965 | switch (event) { |
| 966 | case CLS_ACPT: |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 967 | if (del_timer(&sta->plink_timer)) |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 968 | sta->ignore_plink_timer = 1; |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 969 | mesh_plink_fsm_restart(sta); |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 970 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 971 | break; |
| 972 | case OPN_ACPT: |
| 973 | case CNF_ACPT: |
| 974 | case OPN_RJCT: |
| 975 | case CNF_RJCT: |
| 976 | llid = sta->llid; |
| 977 | reason = sta->reason; |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 978 | spin_unlock_bh(&sta->lock); |
Thomas Pedersen | 54ef656 | 2011-08-11 19:35:12 -0700 | [diff] [blame] | 979 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, |
| 980 | sta->sta.addr, llid, plid, reason); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 981 | break; |
| 982 | default: |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 983 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 984 | } |
| 985 | break; |
| 986 | default: |
Luis Carlos Cobo | b4e08ea | 2008-02-29 15:46:08 -0800 | [diff] [blame] | 987 | /* should not get here, PLINK_BLOCKED is dealt with at the |
Daniel Mack | 3ad2f3fb | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 988 | * beginning of the function |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 989 | */ |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 990 | spin_unlock_bh(&sta->lock); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 991 | break; |
| 992 | } |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 993 | |
| 994 | rcu_read_unlock(); |
Ashok Nagarajan | 57aac7c | 2012-04-30 14:20:30 -0700 | [diff] [blame] | 995 | |
| 996 | if (changed) |
| 997 | ieee80211_bss_info_change_notify(sdata, changed); |
Luis Carlos Cobo | c3896d2 | 2008-02-23 15:17:13 +0100 | [diff] [blame] | 998 | } |