All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] mesh AID fixes
@ 2015-07-14 12:31 Bob Copeland
  2015-07-14 12:31 ` [PATCH v3 1/5] mac80211: correct aid location in peering frames Bob Copeland
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Bob Copeland @ 2015-07-14 12:31 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, devel, Bob Copeland

This patchset removes usage of peer link ID as a stand-in for
AID, in order to follow the standard in this regard.

This revision gained two patches: one was an existing bugfix that
was buried in a reorg patch, and the other is a fix for a missing
length check found while reviewing the code.

Bob Copeland (5):
  mac80211: correct aid location in peering frames
  mac80211: add missing length check for confirm frames
  mac80211: reorder mesh_plink to remove forward decl
  mac80211: mesh: separate plid and aid concepts
  mac80211: select an AID when creating new mesh STAs

 net/mac80211/mesh_plink.c | 172 ++++++++++++++++++++++++++++------------------
 net/mac80211/mesh_ps.c    |   2 +-
 net/mac80211/sta_info.c   |   5 +-
 net/mac80211/sta_info.h   |   2 +
 4 files changed, 108 insertions(+), 73 deletions(-)

-- 
2.1.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 1/5] mac80211: correct aid location in peering frames
  2015-07-14 12:31 [PATCH v3 0/5] mesh AID fixes Bob Copeland
@ 2015-07-14 12:31 ` Bob Copeland
  2015-07-17 12:38   ` Johannes Berg
  2015-07-14 12:31 ` [PATCH v3 2/5] mac80211: add missing length check for confirm frames Bob Copeland
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Bob Copeland @ 2015-07-14 12:31 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, devel, Bob Copeland

According to 802.11-2012 8.5.16.3.2 AID comes directly after the
capability bytes in mesh peering confirm frames.  The existing
code, however, was adding a 2 byte offset to this location,
resulting in garbage data going out over the air.  Remove the
offset to fix it.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
 net/mac80211/mesh_plink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

v3: split out from patch 4

diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index 1a7d98398626..956384087e12 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -306,7 +306,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
 		if (action == WLAN_SP_MESH_PEERING_CONFIRM) {
 			/* AID */
 			pos = skb_put(skb, 2);
-			put_unaligned_le16(plid, pos + 2);
+			put_unaligned_le16(plid, pos);
 		}
 		if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
 		    ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 2/5] mac80211: add missing length check for confirm frames
  2015-07-14 12:31 [PATCH v3 0/5] mesh AID fixes Bob Copeland
  2015-07-14 12:31 ` [PATCH v3 1/5] mac80211: correct aid location in peering frames Bob Copeland
@ 2015-07-14 12:31 ` Bob Copeland
  2015-07-17 12:39   ` Johannes Berg
  2015-07-14 12:31 ` [PATCH v3 3/5] mac80211: reorder mesh_plink to remove forward decl Bob Copeland
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Bob Copeland @ 2015-07-14 12:31 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, devel, Bob Copeland

Although mesh_rx_plink_frame() already checks that frames have enough
bytes for the action code plus another two bytes for capability/reason
code, it doesn't take into account that confirm frames also have an
additional two-byte aid.  As a result, a corrupt frame could cause a
subsequent subtraction to wrap around to ill effect.  Add another
check for this case.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
---

v3: newly introduced

 net/mac80211/mesh_plink.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index 956384087e12..ac1029f28133 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -1123,6 +1123,9 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
 						WLAN_SP_MESH_PEERING_CONFIRM) {
 		baseaddr += 4;
 		baselen += 4;
+
+		if (baselen > len)
+			return;
 	}
 	ieee802_11_parse_elems(baseaddr, len - baselen, true, &elems);
 	mesh_process_plink_frame(sdata, mgmt, &elems);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 3/5] mac80211: reorder mesh_plink to remove forward decl
  2015-07-14 12:31 [PATCH v3 0/5] mesh AID fixes Bob Copeland
  2015-07-14 12:31 ` [PATCH v3 1/5] mac80211: correct aid location in peering frames Bob Copeland
  2015-07-14 12:31 ` [PATCH v3 2/5] mac80211: add missing length check for confirm frames Bob Copeland
@ 2015-07-14 12:31 ` Bob Copeland
  2015-07-14 12:31 ` [PATCH v3 4/5] mac80211: mesh: separate plid and aid concepts Bob Copeland
  2015-07-14 12:31 ` [PATCH v3 5/5] mac80211: select an AID when creating new mesh STAs Bob Copeland
  4 siblings, 0 replies; 12+ messages in thread
From: Bob Copeland @ 2015-07-14 12:31 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, devel, Bob Copeland

Move mesh_plink_frame_tx() above the first caller to remove
the forward declaration.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
---

v3: unchanged from v1

 net/mac80211/mesh_plink.c | 109 ++++++++++++++++++++++------------------------
 1 file changed, 52 insertions(+), 57 deletions(-)

diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index ac1029f28133..a5aa0345dd7e 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -53,11 +53,6 @@ static const char * const mplevents[] = {
 	[CLS_IGNR] = "CLS_IGNR"
 };
 
-static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
-			       enum ieee80211_self_protected_actioncode action,
-			       u8 *da, u16 llid, u16 plid, u16 reason);
-
-
 /* We only need a valid sta if user configured a minimum rssi_threshold. */
 static bool rssi_threshold_check(struct ieee80211_sub_if_data *sdata,
 				 struct sta_info *sta)
@@ -204,58 +199,6 @@ static u32 mesh_set_ht_prot_mode(struct ieee80211_sub_if_data *sdata)
 	return BSS_CHANGED_HT;
 }
 
-/**
- * __mesh_plink_deactivate - deactivate mesh peer link
- *
- * @sta: mesh peer link to deactivate
- *
- * All mesh paths with this peer as next hop will be flushed
- * Returns beacon changed flag if the beacon content changed.
- *
- * Locking: the caller must hold sta->mesh->plink_lock
- */
-static u32 __mesh_plink_deactivate(struct sta_info *sta)
-{
-	struct ieee80211_sub_if_data *sdata = sta->sdata;
-	u32 changed = 0;
-
-	lockdep_assert_held(&sta->mesh->plink_lock);
-
-	if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
-		changed = mesh_plink_dec_estab_count(sdata);
-	sta->mesh->plink_state = NL80211_PLINK_BLOCKED;
-	mesh_path_flush_by_nexthop(sta);
-
-	ieee80211_mps_sta_status_update(sta);
-	changed |= ieee80211_mps_set_sta_local_pm(sta,
-			NL80211_MESH_POWER_UNKNOWN);
-
-	return changed;
-}
-
-/**
- * mesh_plink_deactivate - deactivate mesh peer link
- *
- * @sta: mesh peer link to deactivate
- *
- * All mesh paths with this peer as next hop will be flushed
- */
-u32 mesh_plink_deactivate(struct sta_info *sta)
-{
-	struct ieee80211_sub_if_data *sdata = sta->sdata;
-	u32 changed;
-
-	spin_lock_bh(&sta->mesh->plink_lock);
-	changed = __mesh_plink_deactivate(sta);
-	sta->mesh->reason = WLAN_REASON_MESH_PEER_CANCELED;
-	mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
-			    sta->sta.addr, sta->mesh->llid, sta->mesh->plid,
-			    sta->mesh->reason);
-	spin_unlock_bh(&sta->mesh->plink_lock);
-
-	return changed;
-}
-
 static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
 			       enum ieee80211_self_protected_actioncode action,
 			       u8 *da, u16 llid, u16 plid, u16 reason)
@@ -375,6 +318,58 @@ free:
 	return err;
 }
 
+/**
+ * __mesh_plink_deactivate - deactivate mesh peer link
+ *
+ * @sta: mesh peer link to deactivate
+ *
+ * All mesh paths with this peer as next hop will be flushed
+ * Returns beacon changed flag if the beacon content changed.
+ *
+ * Locking: the caller must hold sta->mesh->plink_lock
+ */
+static u32 __mesh_plink_deactivate(struct sta_info *sta)
+{
+	struct ieee80211_sub_if_data *sdata = sta->sdata;
+	u32 changed = 0;
+
+	lockdep_assert_held(&sta->mesh->plink_lock);
+
+	if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
+		changed = mesh_plink_dec_estab_count(sdata);
+	sta->mesh->plink_state = NL80211_PLINK_BLOCKED;
+	mesh_path_flush_by_nexthop(sta);
+
+	ieee80211_mps_sta_status_update(sta);
+	changed |= ieee80211_mps_set_sta_local_pm(sta,
+			NL80211_MESH_POWER_UNKNOWN);
+
+	return changed;
+}
+
+/**
+ * mesh_plink_deactivate - deactivate mesh peer link
+ *
+ * @sta: mesh peer link to deactivate
+ *
+ * All mesh paths with this peer as next hop will be flushed
+ */
+u32 mesh_plink_deactivate(struct sta_info *sta)
+{
+	struct ieee80211_sub_if_data *sdata = sta->sdata;
+	u32 changed;
+
+	spin_lock_bh(&sta->mesh->plink_lock);
+	changed = __mesh_plink_deactivate(sta);
+	sta->mesh->reason = WLAN_REASON_MESH_PEER_CANCELED;
+	mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
+			    sta->sta.addr, sta->mesh->llid, sta->mesh->plid,
+			    sta->mesh->reason);
+	spin_unlock_bh(&sta->mesh->plink_lock);
+
+	return changed;
+}
+
 static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata,
 			       struct sta_info *sta,
 			       struct ieee802_11_elems *elems, bool insert)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 4/5] mac80211: mesh: separate plid and aid concepts
  2015-07-14 12:31 [PATCH v3 0/5] mesh AID fixes Bob Copeland
                   ` (2 preceding siblings ...)
  2015-07-14 12:31 ` [PATCH v3 3/5] mac80211: reorder mesh_plink to remove forward decl Bob Copeland
@ 2015-07-14 12:31 ` Bob Copeland
  2015-07-14 12:31 ` [PATCH v3 5/5] mac80211: select an AID when creating new mesh STAs Bob Copeland
  4 siblings, 0 replies; 12+ messages in thread
From: Bob Copeland @ 2015-07-14 12:31 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, devel, Bob Copeland

According to 802.11-2012 13.3.1, a mesh STA should assign an AID
upon receipt of a mesh peering open frame rather than using the link
id of the peer.  Using the peer link id has two potential issues:
it may not be unique among the peers, and by its nature it is random,
so the TIM may not compress well.

In preparation for allocating it properly, use sta->sta.aid, but keep
the existing behavior of using the plid in the aid we send.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
v3:
   - introduce local aid and parse it from confirm frame
   - split out bugfix for aid pos

 net/mac80211/mesh_plink.c | 29 +++++++++++++++++++----------
 net/mac80211/mesh_ps.c    |  2 +-
 net/mac80211/sta_info.c   |  5 +----
 net/mac80211/sta_info.h   |  2 ++
 4 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index a5aa0345dd7e..3323413acb77 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -13,6 +13,7 @@
 #include "rate.h"
 #include "mesh.h"
 
+#define PLINK_CNF_AID(mgmt) ((mgmt)->u.action.u.self_prot.variable + 2)
 #define PLINK_GET_LLID(p) (p + 2)
 #define PLINK_GET_PLID(p) (p + 4)
 
@@ -200,6 +201,7 @@ static u32 mesh_set_ht_prot_mode(struct ieee80211_sub_if_data *sdata)
 }
 
 static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
+			       struct sta_info *sta,
 			       enum ieee80211_self_protected_actioncode action,
 			       u8 *da, u16 llid, u16 plid, u16 reason)
 {
@@ -249,7 +251,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
 		if (action == WLAN_SP_MESH_PEERING_CONFIRM) {
 			/* AID */
 			pos = skb_put(skb, 2);
-			put_unaligned_le16(plid, pos);
+			put_unaligned_le16(sta->sta.aid, pos);
 		}
 		if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
 		    ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
@@ -362,7 +364,7 @@ u32 mesh_plink_deactivate(struct sta_info *sta)
 	spin_lock_bh(&sta->mesh->plink_lock);
 	changed = __mesh_plink_deactivate(sta);
 	sta->mesh->reason = WLAN_REASON_MESH_PEER_CANCELED;
-	mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
+	mesh_plink_frame_tx(sdata, sta, WLAN_SP_MESH_PEERING_CLOSE,
 			    sta->sta.addr, sta->mesh->llid, sta->mesh->plid,
 			    sta->mesh->reason);
 	spin_unlock_bh(&sta->mesh->plink_lock);
@@ -619,7 +621,7 @@ static void mesh_plink_timer(unsigned long data)
 	}
 	spin_unlock_bh(&sta->mesh->plink_lock);
 	if (action)
-		mesh_plink_frame_tx(sdata, action, sta->sta.addr,
+		mesh_plink_frame_tx(sdata, sta, action, sta->sta.addr,
 				    sta->mesh->llid, sta->mesh->plid, reason);
 }
 
@@ -689,7 +691,7 @@ u32 mesh_plink_open(struct sta_info *sta)
 	/* set the non-peer mode to active during peering */
 	changed = ieee80211_mps_local_status_update(sdata);
 
-	mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_OPEN,
+	mesh_plink_frame_tx(sdata, sta, WLAN_SP_MESH_PEERING_OPEN,
 			    sta->sta.addr, sta->mesh->llid, 0, 0);
 	return changed;
 }
@@ -871,13 +873,13 @@ static u32 mesh_plink_fsm(struct ieee80211_sub_if_data *sdata,
 	}
 	spin_unlock_bh(&sta->mesh->plink_lock);
 	if (action) {
-		mesh_plink_frame_tx(sdata, action, sta->sta.addr,
+		mesh_plink_frame_tx(sdata, sta, action, sta->sta.addr,
 				    sta->mesh->llid, sta->mesh->plid,
 				    sta->mesh->reason);
 
 		/* also send confirm in open case */
 		if (action == WLAN_SP_MESH_PEERING_OPEN) {
-			mesh_plink_frame_tx(sdata,
+			mesh_plink_frame_tx(sdata, sta,
 					    WLAN_SP_MESH_PEERING_CONFIRM,
 					    sta->sta.addr, sta->mesh->llid,
 					    sta->mesh->plid, 0);
@@ -1067,8 +1069,9 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata,
 			goto unlock_rcu;
 		}
 		sta->mesh->plid = plid;
+		sta->sta.aid = plid;
 	} else if (!sta && event == OPN_RJCT) {
-		mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
+		mesh_plink_frame_tx(sdata, NULL, WLAN_SP_MESH_PEERING_CLOSE,
 				    mgmt->sa, 0, plid,
 				    WLAN_REASON_MESH_CONFIG);
 		goto unlock_rcu;
@@ -1077,9 +1080,15 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata,
 		goto unlock_rcu;
 	}
 
-	/* 802.11-2012 13.3.7.2 - update plid on CNF if not set */
-	if (!sta->mesh->plid && event == CNF_ACPT)
-		sta->mesh->plid = plid;
+	if (event == CNF_ACPT) {
+		/* 802.11-2012 13.3.7.2 - update plid on CNF if not set */
+		if (!sta->mesh->plid) {
+			sta->mesh->plid = plid;
+			sta->sta.aid = sta->mesh->plid;
+		}
+
+		sta->mesh->aid = get_unaligned_le16(PLINK_CNF_AID(mgmt));
+	}
 
 	changed |= mesh_plink_fsm(sdata, sta, event);
 
diff --git a/net/mac80211/mesh_ps.c b/net/mac80211/mesh_ps.c
index 29747f92b9b0..90a268abea17 100644
--- a/net/mac80211/mesh_ps.c
+++ b/net/mac80211/mesh_ps.c
@@ -579,7 +579,7 @@ void ieee80211_mps_frame_release(struct sta_info *sta,
 
 	if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
 		has_buffered = ieee80211_check_tim(elems->tim, elems->tim_len,
-						   sta->mesh->llid);
+						   sta->mesh->aid);
 
 	if (has_buffered)
 		mps_dbg(sta->sdata, "%pM indicates buffered frames\n",
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 9da7d2bc271a..70cd9fa57424 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -635,7 +635,7 @@ static void __sta_info_recalc_tim(struct sta_info *sta, bool ignore_pending)
 	bool indicate_tim = false;
 	u8 ignore_for_tim = sta->sta.uapsd_queues;
 	int ac;
-	u16 id;
+	u16 id = sta->sta.aid;
 
 	if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
 	    sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
@@ -643,12 +643,9 @@ static void __sta_info_recalc_tim(struct sta_info *sta, bool ignore_pending)
 			return;
 
 		ps = &sta->sdata->bss->ps;
-		id = sta->sta.aid;
 #ifdef CONFIG_MAC80211_MESH
 	} else if (ieee80211_vif_is_mesh(&sta->sdata->vif)) {
 		ps = &sta->sdata->u.mesh.ps;
-		/* TIM map only for 1 <= PLID <= IEEE80211_MAX_AID */
-		id = sta->mesh->plid % (IEEE80211_MAX_AID + 1);
 #endif
 	} else {
 		return;
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 6dcb33484eac..1d2805c598c0 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -277,6 +277,7 @@ struct ieee80211_fast_tx {
  * @plink_lock: serialize access to plink fields
  * @llid: Local link ID
  * @plid: Peer link ID
+ * @aid: local aid supplied by peer
  * @reason: Cancel reason on PLINK_HOLDING state
  * @plink_retries: Retries in establishment
  * @plink_state: peer link state
@@ -301,6 +302,7 @@ struct mesh_sta {
 	spinlock_t plink_lock;
 	u16 llid;
 	u16 plid;
+	u16 aid;
 	u16 reason;
 	u8 plink_retries;
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 5/5] mac80211: select an AID when creating new mesh STAs
  2015-07-14 12:31 [PATCH v3 0/5] mesh AID fixes Bob Copeland
                   ` (3 preceding siblings ...)
  2015-07-14 12:31 ` [PATCH v3 4/5] mac80211: mesh: separate plid and aid concepts Bob Copeland
@ 2015-07-14 12:31 ` Bob Copeland
  2015-07-17 13:48   ` Johannes Berg
  4 siblings, 1 reply; 12+ messages in thread
From: Bob Copeland @ 2015-07-14 12:31 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, devel, Bob Copeland

Instead of using peer link id for AID, generate a new
AID when creating mesh STAs in the kernel peering manager.
This enables smaller TIM elements and more closely follows
the standard, and it also enables mesh to work on drivers
that require a valid AID when the STA is inserted (ath10k
firmware has this requirement, for example).

In the case of userspace-managed stations, we use the AID
from NL80211_CMD_NEW_STATION.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
---

v2: generate the bitmap as needed inside mesh_allocate_aid rather
than maintaining the whole time (Johannes)

v3: unchanged from v2

 net/mac80211/mesh_plink.c | 41 +++++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index 3323413acb77..e12be2e4e8df 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -422,20 +422,54 @@ out:
 	spin_unlock_bh(&sta->mesh->plink_lock);
 }
 
+static int mesh_allocate_aid(struct ieee80211_sub_if_data *sdata)
+{
+	struct sta_info *sta;
+	unsigned long *aid_map;
+	int aid;
+
+	aid_map = kcalloc(BITS_TO_LONGS(IEEE80211_MAX_AID + 1),
+			  sizeof(*aid_map), GFP_KERNEL);
+	if (!aid_map)
+		return -ENOMEM;
+
+	/* reserve aid 0 for mcast indication */
+	__set_bit(0, aid_map);
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(sta, &sdata->local->sta_list, list)
+		__set_bit(sta->sta.aid, aid_map);
+	rcu_read_unlock();
+
+	aid = find_first_zero_bit(aid_map, IEEE80211_MAX_AID + 1);
+	kfree(aid_map);
+
+	if (aid > IEEE80211_MAX_AID)
+		return -ENOBUFS;
+
+	return aid;
+}
+
 static struct sta_info *
 __mesh_sta_info_alloc(struct ieee80211_sub_if_data *sdata, u8 *hw_addr)
 {
 	struct sta_info *sta;
+	int aid;
 
 	if (sdata->local->num_sta >= MESH_MAX_PLINKS)
 		return NULL;
 
+	aid = mesh_allocate_aid(sdata);
+	if (aid < 0)
+		return NULL;
+
 	sta = sta_info_alloc(sdata, hw_addr, GFP_KERNEL);
 	if (!sta)
 		return NULL;
 
 	sta->mesh->plink_state = NL80211_PLINK_LISTEN;
 	sta->sta.wme = true;
+	sta->sta.aid = aid;
 
 	sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
 	sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
@@ -659,8 +693,6 @@ static u16 mesh_get_new_llid(struct ieee80211_sub_if_data *sdata)
 
 	do {
 		get_random_bytes(&llid, sizeof(llid));
-		/* for mesh PS we still only have the AID range for TIM bits */
-		llid = (llid % IEEE80211_MAX_AID) + 1;
 	} while (llid_in_use(sdata, llid));
 
 	return llid;
@@ -1069,7 +1101,6 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata,
 			goto unlock_rcu;
 		}
 		sta->mesh->plid = plid;
-		sta->sta.aid = plid;
 	} else if (!sta && event == OPN_RJCT) {
 		mesh_plink_frame_tx(sdata, NULL, WLAN_SP_MESH_PEERING_CLOSE,
 				    mgmt->sa, 0, plid,
@@ -1082,10 +1113,8 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata,
 
 	if (event == CNF_ACPT) {
 		/* 802.11-2012 13.3.7.2 - update plid on CNF if not set */
-		if (!sta->mesh->plid) {
+		if (!sta->mesh->plid)
 			sta->mesh->plid = plid;
-			sta->sta.aid = sta->mesh->plid;
-		}
 
 		sta->mesh->aid = get_unaligned_le16(PLINK_CNF_AID(mgmt));
 	}
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 1/5] mac80211: correct aid location in peering frames
  2015-07-14 12:31 ` [PATCH v3 1/5] mac80211: correct aid location in peering frames Bob Copeland
@ 2015-07-17 12:38   ` Johannes Berg
  0 siblings, 0 replies; 12+ messages in thread
From: Johannes Berg @ 2015-07-17 12:38 UTC (permalink / raw)
  To: Bob Copeland; +Cc: linux-wireless, devel

On Tue, 2015-07-14 at 08:31 -0400, Bob Copeland wrote:
> According to 802.11-2012 8.5.16.3.2 AID comes directly after the
> capability bytes in mesh peering confirm frames.  The existing
> code, however, was adding a 2 byte offset to this location,
> resulting in garbage data going out over the air.  Remove the
> offset to fix it.
> 
applied (to mac80211.git)

johannes

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 2/5] mac80211: add missing length check for confirm frames
  2015-07-14 12:31 ` [PATCH v3 2/5] mac80211: add missing length check for confirm frames Bob Copeland
@ 2015-07-17 12:39   ` Johannes Berg
  0 siblings, 0 replies; 12+ messages in thread
From: Johannes Berg @ 2015-07-17 12:39 UTC (permalink / raw)
  To: Bob Copeland; +Cc: linux-wireless, devel

On Tue, 2015-07-14 at 08:31 -0400, Bob Copeland wrote:
> Although mesh_rx_plink_frame() already checks that frames have enough
> bytes for the action code plus another two bytes for 
> capability/reason
> code, it doesn't take into account that confirm frames also have an
> additional two-byte aid.  As a result, a corrupt frame could cause a
> subsequent subtraction to wrap around to ill effect.  Add another
> check for this case.
> 
Also applied.

johannes

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 5/5] mac80211: select an AID when creating new mesh STAs
  2015-07-14 12:31 ` [PATCH v3 5/5] mac80211: select an AID when creating new mesh STAs Bob Copeland
@ 2015-07-17 13:48   ` Johannes Berg
  2015-07-17 14:48     ` Johannes Berg
  0 siblings, 1 reply; 12+ messages in thread
From: Johannes Berg @ 2015-07-17 13:48 UTC (permalink / raw)
  To: Bob Copeland; +Cc: linux-wireless, devel

On Tue, 2015-07-14 at 08:31 -0400, Bob Copeland wrote:
> Instead of using peer link id for AID, generate a new
> AID when creating mesh STAs in the kernel peering manager.
> This enables smaller TIM elements and more closely follows
> the standard, and it also enables mesh to work on drivers
> that require a valid AID when the STA is inserted (ath10k
> firmware has this requirement, for example).
> 
> In the case of userspace-managed stations, we use the AID
> from NL80211_CMD_NEW_STATION.
> 
Applied the remaining 3 patches to mac80211-next (after merging
mac80211)

johannes

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 5/5] mac80211: select an AID when creating new mesh STAs
  2015-07-17 13:48   ` Johannes Berg
@ 2015-07-17 14:48     ` Johannes Berg
  2015-07-17 14:50       ` Johannes Berg
  0 siblings, 1 reply; 12+ messages in thread
From: Johannes Berg @ 2015-07-17 14:48 UTC (permalink / raw)
  To: Bob Copeland; +Cc: linux-wireless, devel

On Fri, 2015-07-17 at 15:48 +0200, Johannes Berg wrote:
> On Tue, 2015-07-14 at 08:31 -0400, Bob Copeland wrote:
> > Instead of using peer link id for AID, generate a new
> > AID when creating mesh STAs in the kernel peering manager.
> > This enables smaller TIM elements and more closely follows
> > the standard, and it also enables mesh to work on drivers
> > that require a valid AID when the STA is inserted (ath10k
> > firmware has this requirement, for example).
> > 
> > In the case of userspace-managed stations, we use the AID
> > from NL80211_CMD_NEW_STATION.
> > 
> Applied the remaining 3 patches to mac80211-next (after merging
> mac80211)
> 

Actually, I'm dropping this one (the 5th) as it broke all the wpa_s
mesh test cases. Perhaps wpa_s isn't assigning an AID and mac80211
needs a fallback?

johannes

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 5/5] mac80211: select an AID when creating new mesh STAs
  2015-07-17 14:48     ` Johannes Berg
@ 2015-07-17 14:50       ` Johannes Berg
  2015-07-17 15:13         ` Bob Copeland
  0 siblings, 1 reply; 12+ messages in thread
From: Johannes Berg @ 2015-07-17 14:50 UTC (permalink / raw)
  To: Bob Copeland; +Cc: linux-wireless, devel

On Fri, 2015-07-17 at 16:48 +0200, Johannes Berg wrote:
> On Fri, 2015-07-17 at 15:48 +0200, Johannes Berg wrote:
> > On Tue, 2015-07-14 at 08:31 -0400, Bob Copeland wrote:
> > > Instead of using peer link id for AID, generate a new
> > > AID when creating mesh STAs in the kernel peering manager.
> > > This enables smaller TIM elements and more closely follows
> > > the standard, and it also enables mesh to work on drivers
> > > that require a valid AID when the STA is inserted (ath10k
> > > firmware has this requirement, for example).
> > > 
> > > In the case of userspace-managed stations, we use the AID
> > > from NL80211_CMD_NEW_STATION.
> > > 
> > Applied the remaining 3 patches to mac80211-next (after merging
> > mac80211)
> > 
> 
> Actually, I'm dropping this one (the 5th) as it broke all the wpa_s
> mesh test cases. Perhaps wpa_s isn't assigning an AID and mac80211
> needs a fallback?
> 

Actually, it also fails without any of your patches, so I guess it's
some other issue. I'll keep these and sort it out when I'm back.

johannes

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 5/5] mac80211: select an AID when creating new mesh STAs
  2015-07-17 14:50       ` Johannes Berg
@ 2015-07-17 15:13         ` Bob Copeland
  0 siblings, 0 replies; 12+ messages in thread
From: Bob Copeland @ 2015-07-17 15:13 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, devel

On Fri, Jul 17, 2015 at 04:50:56PM +0200, Johannes Berg wrote:
> > Actually, I'm dropping this one (the 5th) as it broke all the wpa_s
> > mesh test cases. Perhaps wpa_s isn't assigning an AID and mac80211
> > needs a fallback?
> > 
> 
> Actually, it also fails without any of your patches, so I guess it's
> some other issue. I'll keep these and sort it out when I'm back.

Ok, thanks for the heads-up.  I ran them against wpa_s and didn't notice
any breakage, but will retest against your tree over the weekend.

-- 
Bob Copeland %% http://bobcopeland.com/

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-07-17 15:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 12:31 [PATCH v3 0/5] mesh AID fixes Bob Copeland
2015-07-14 12:31 ` [PATCH v3 1/5] mac80211: correct aid location in peering frames Bob Copeland
2015-07-17 12:38   ` Johannes Berg
2015-07-14 12:31 ` [PATCH v3 2/5] mac80211: add missing length check for confirm frames Bob Copeland
2015-07-17 12:39   ` Johannes Berg
2015-07-14 12:31 ` [PATCH v3 3/5] mac80211: reorder mesh_plink to remove forward decl Bob Copeland
2015-07-14 12:31 ` [PATCH v3 4/5] mac80211: mesh: separate plid and aid concepts Bob Copeland
2015-07-14 12:31 ` [PATCH v3 5/5] mac80211: select an AID when creating new mesh STAs Bob Copeland
2015-07-17 13:48   ` Johannes Berg
2015-07-17 14:48     ` Johannes Berg
2015-07-17 14:50       ` Johannes Berg
2015-07-17 15:13         ` Bob Copeland

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.