Skip to contentSkip to conversation

implement active mesh scanning

PATCH Superseded Thomas Pedersen 2 participants 12 messages Feb 3, 2013 – Feb 4, 2013 mac80211

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover implement active mesh scanning

This set improves the mesh scanning functionality by:

- responding to broadcast or directed probe requests
- allowing the user to generate a directed mesh probe request, ie:
iw mesh0 scan ssid foo
on a mesh interface will send probe requests where the ssid "foo" has been filled into the mesh ID IE.

Also patch 1 caches the mesh beacon in a struct beacon_data each time it changes so probe responses can be quickly built. This is also convenient when the TIM IE becomes needed for PS.

Applies on mac80211-next/master

Thomas Pedersen (3):
mac80211: cache mesh beacon
mac80211: generate mesh probe requests
mac80211: generate mesh probe responses

 net/mac80211/cfg.c         |    2 +
 net/mac80211/ieee80211_i.h |    1 +
 net/mac80211/mesh.c        |  199 +++++++++++++++++++++++++++++++++++++++++++-
 net/mac80211/mesh.h        |    3 +
 net/mac80211/mesh_plink.c  |    6 +-
 net/mac80211/rx.c          |    5 +-
 net/mac80211/tx.c          |   72 +++++-----------
 net/mac80211/util.c        |    1 +
 8 files changed, 229 insertions(+), 60 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/3 mac80211: cache mesh beacon

Previously, the entire mesh beacon would be generated each time the beacon timer fired. Instead generate a beacon head and tail (so the TIM can easily be inserted when mesh power save is on) when starting a mesh or the MBSS parameters change.

---
 net/mac80211/cfg.c         |    2 +
 net/mac80211/ieee80211_i.h |    1 +
 net/mac80211/mesh.c        |  136 +++++++++++++++++++++++++++++++++++++++++++-
 net/mac80211/mesh.h        |    3 +
 net/mac80211/mesh_plink.c  |    6 +-
 net/mac80211/tx.c          |   57 +++----------------
 6 files changed, 151 insertions(+), 54 deletions(-)
net/mac80211/cfg.c +2 -0
index 661b878..f3ca170 100644
@@ -1777,6 +1777,8 @@ static int ieee80211_update_mesh_config(struct wiphy *wiphy,
 	if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
 		conf->dot11MeshHWMPconfirmationInterval =
 			nconf->dot11MeshHWMPconfirmationInterval;
+	/* need to update the IEs as well */
+	ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
 	return 0;
 }
 
net/mac80211/ieee80211_i.h +1 -0
index c9c66de..48efad8 100644
@@ -581,6 +581,7 @@ struct ieee80211_if_mesh {
 	u32 mesh_seqnum;
 	bool accepting_plinks;
 	int num_gates;
+	struct beacon_data __rcu *beacon;
 	const u8 *ie;
 	u8 ie_len;
 	enum {
net/mac80211/mesh.c +134 -2

160 lines not on this page · raw message

net/mac80211/mesh.h +3 -0
index aff3015..e6377ec 100644
@@ -241,6 +241,9 @@ void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
 void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
 void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
 const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method);
+/* wrapper for ieee80211_bss_info_change_notify() */
+int ieee80211_mbss_info_change_notify(struct ieee80211_sub_if_data *sdata,
+				      u32 changed);
 
 /* Mesh paths */
 int mesh_nexthop_lookup(struct sk_buff *skb,
net/mac80211/mesh_plink.c +3 -3
index 6787d69..4708170 100644
@@ -224,7 +224,7 @@ void mesh_plink_deactivate(struct sta_info *sta)
 			    sta->reason);
 	spin_unlock_bh(&sta->lock);
 
-	ieee80211_bss_info_change_notify(sdata, changed);
+	ieee80211_mbss_info_change_notify(sdata, changed);
 }
 
 static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
@@ -647,7 +647,7 @@ void mesh_plink_block(struct sta_info *sta)
 	sta->plink_state = NL80211_PLINK_BLOCKED;
 	spin_unlock_bh(&sta->lock);
 
-	ieee80211_bss_info_change_notify(sdata, changed);
+	ieee80211_mbss_info_change_notify(sdata, changed);
 }
 
 
@@ -1065,5 +1065,5 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
 	rcu_read_unlock();
 
 	if (changed)
-		ieee80211_bss_info_change_notify(sdata, changed);
+		ieee80211_mbss_info_change_notify(sdata, changed);
 }
net/mac80211/tx.c +8 -49

74 lines not on this page · raw message

Signature · 1 line
1.7.10.4
maintainer
#2 lore raw

Re: [PATCH 1/3] mac80211: cache mesh beacon

Quoted 13 lines
net/mac80211/mesh.c +12 -0
+static int
+ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)
+{
+	struct beacon_data *bcn;
+	int head_len, tail_len;
+	struct sk_buff *skb;
+	struct ieee80211_mgmt *mgmt;
+	struct ieee80211_chanctx_conf *chanctx_conf;
+	enum ieee80211_band band;
+	u8 *pos;
+	struct ieee80211_sub_if_data *sdata;
+	int hdr_len = offsetof(struct ieee80211_mgmt, u.beacon) +

net/mac80211/mesh.c void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) · line 622

Quoted 10 lines
net/mac80211/mesh.c +10 -0
+		      sizeof(mgmt->u.beacon);
+
+	sdata = container_of(ifmsh, struct ieee80211_sub_if_data, u.mesh);
+	rcu_read_lock();
+	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
+	band = chanctx_conf->def.chan->band;
+	rcu_read_unlock();
+
+	RCU_INIT_POINTER(ifmsh->beacon, NULL);
+	synchronize_rcu();

That doesn't seem right? Why force to NULL and synchronize, instead of just building an update and overwriting the old beacon with the new, using kfree_rcu() to get rid of the old afterwards? synchronize_rcu() is quite expensive (might take hundreds of milliseconds.)

Also, doesn't this just leak the old one?

net/mac80211/mesh.c void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) · line 637

Quoted 2 lines
net/mac80211/mesh.c +2 -0
+	/* need an skb for IE builders to operate on */
+	skb = dev_alloc_skb(max(head_len, tail_len));

Heh. Might consider changing the IE builder functions?

net/mac80211/mesh.c void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) · line 709

Quoted 11 lines
net/mac80211/mesh.c +11 -0
+static int
+ieee80211_mesh_rebuild_beacon(struct ieee80211_if_mesh *ifmsh)
+{
+	struct ieee80211_sub_if_data *sdata;
+	sdata = container_of(ifmsh, struct ieee80211_sub_if_data, u.mesh);
+
+	rcu_read_lock();
+	kfree(rcu_dereference(ifmsh->beacon));
+	rcu_read_unlock();
+
+	if (WARN_ON(ieee80211_mesh_build_beacon(ifmsh))) {

The warning is probably not a good idea since it's really for allocation failures only which already print long messages.

net/mac80211/mesh.c void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) · line 711

Quoted 2 lines
net/mac80211/mesh.c +2 -0
+		mpl_dbg(sdata, "couldn't rebuild mesh beacon, stopping!\n");
+		ieee80211_stop_mesh(sdata);

I'm not sure that's such a good idea? Nothing in userspace would expect to randomly stop the mesh.

Review

Quoted 1 line
(quoted diff) +1 -0
+		return -1;

Why not have a proper error code and propagate it properly? :)

johannes

#3 lore raw

Re: [PATCH 1/3] mac80211: cache mesh beacon

Quoted 20 lines · Johannes Berg
Quoted 20 lines
net/mac80211/mesh.c +19 -0
+static int
+ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)
+{
+     struct beacon_data *bcn;
+     int head_len, tail_len;
+     struct sk_buff *skb;
+     struct ieee80211_mgmt *mgmt;
+     struct ieee80211_chanctx_conf *chanctx_conf;
+     enum ieee80211_band band;
+     u8 *pos;
+     struct ieee80211_sub_if_data *sdata;
+     int hdr_len = offsetof(struct ieee80211_mgmt, u.beacon) +
+                   sizeof(mgmt->u.beacon);
+
+     sdata = container_of(ifmsh, struct ieee80211_sub_if_data, u.mesh);
+     rcu_read_lock();
+     chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
+     band = chanctx_conf->def.chan->band;
+     rcu_read_unlock();
Quoted 8 lines

net/mac80211/mesh.c void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) · line 622

Quoted 3 lines
net/mac80211/mesh.c +3 -0
+
+     RCU_INIT_POINTER(ifmsh->beacon, NULL);
+     synchronize_rcu();

That doesn't seem right? Why force to NULL and synchronize, instead of just building an update and overwriting the old beacon with the new, using kfree_rcu() to get rid of the old afterwards? synchronize_rcu() is quite expensive (might take hundreds of milliseconds.)

OK, I just copied this from the IBSS code. Overwriting the old one makes sense though.

Quoted 1 line

Also, doesn't this just leak the old one?

ieee80211_mesh_rebuild_beacon() will free it, but maybe that doesn't make sense.

Quoted 4 lines

net/mac80211/mesh.c void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) · line 637

Quoted 2 lines
net/mac80211/mesh.c +2 -0
+     /* need an skb for IE builders to operate on */
+     skb = dev_alloc_skb(max(head_len, tail_len));

Heh. Might consider changing the IE builder functions?

Some IEs are variable length though, so I like how they append (and can check for space) the right length to skb->len.

Quoted 6 lines
Quoted 6 lines
net/mac80211/mesh.c +6 -0
+static int
+ieee80211_mesh_rebuild_beacon(struct ieee80211_if_mesh *ifmsh)
+{
+     struct ieee80211_sub_if_data *sdata;
+     sdata = container_of(ifmsh, struct ieee80211_sub_if_data, u.mesh);
+
Quoted 8 lines

net/mac80211/mesh.c void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) · line 709

Quoted 5 lines
net/mac80211/mesh.c +5 -0
+     rcu_read_lock();
+     kfree(rcu_dereference(ifmsh->beacon));
+     rcu_read_unlock();
+
+     if (WARN_ON(ieee80211_mesh_build_beacon(ifmsh))) {

The warning is probably not a good idea since it's really for allocation failures only which already print long messages.

OK.

Quoted 5 lines

net/mac80211/mesh.c void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) · line 711

Quoted 2 lines
net/mac80211/mesh.c +2 -0
+             mpl_dbg(sdata, "couldn't rebuild mesh beacon, stopping!\n");
+             ieee80211_stop_mesh(sdata);

I'm not sure that's such a good idea? Nothing in userspace would expect to randomly stop the mesh.

So if rebuilding failed, just continue with the old beacon?

Quoted 3 lines
Quoted 1 line

+ return -1;

Why not have a proper error code and propagate it properly? :)

OK.

Signature · 1 line
Thomas
maintainer
#4 lore raw

Re: [PATCH 1/3] mac80211: cache mesh beacon

Quoted 30 lines · Thomas Pedersen
Quoted 20 lines · Johannes Berg
Quoted 20 lines
net/mac80211/mesh.c +19 -0
+static int
+ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)
+{
+     struct beacon_data *bcn;
+     int head_len, tail_len;
+     struct sk_buff *skb;
+     struct ieee80211_mgmt *mgmt;
+     struct ieee80211_chanctx_conf *chanctx_conf;
+     enum ieee80211_band band;
+     u8 *pos;
+     struct ieee80211_sub_if_data *sdata;
+     int hdr_len = offsetof(struct ieee80211_mgmt, u.beacon) +
+                   sizeof(mgmt->u.beacon);
+
+     sdata = container_of(ifmsh, struct ieee80211_sub_if_data, u.mesh);
+     rcu_read_lock();
+     chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
+     band = chanctx_conf->def.chan->band;
+     rcu_read_unlock();
Quoted 8 lines

net/mac80211/mesh.c void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) · line 622

Quoted 3 lines
net/mac80211/mesh.c +3 -0
+
+     RCU_INIT_POINTER(ifmsh->beacon, NULL);
+     synchronize_rcu();

That doesn't seem right? Why force to NULL and synchronize, instead of just building an update and overwriting the old beacon with the new, using kfree_rcu() to get rid of the old afterwards? synchronize_rcu() is quite expensive (might take hundreds of milliseconds.)

Quoted 2 lines

OK, I just copied this from the IBSS code. Overwriting the old one makes sense though.

What? I should check that out. OTOH, IBSS code never really changes its beacon during operation, I think, so it might not matter much there?

Quoted 7 lines
Quoted 4 lines

net/mac80211/mesh.c void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) · line 637

Quoted 2 lines
net/mac80211/mesh.c +2 -0
+     /* need an skb for IE builders to operate on */
+     skb = dev_alloc_skb(max(head_len, tail_len));

Heh. Might consider changing the IE builder functions?

Some IEs are variable length though, so I like how they append (and can check for space) the right length to skb->len.

Fair enough. It seemed a bit odd but I'm not worried about it.

Quoted 7 lines
Quoted 5 lines

net/mac80211/mesh.c void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) · line 711

Quoted 2 lines
net/mac80211/mesh.c +2 -0
+             mpl_dbg(sdata, "couldn't rebuild mesh beacon, stopping!\n");
+             ieee80211_stop_mesh(sdata);

I'm not sure that's such a good idea? Nothing in userspace would expect to randomly stop the mesh.

So if rebuilding failed, just continue with the old beacon?

That seems acceptable to me. You're probably running into bigger issues if allocating a little bit of memory here already fails.

johannes

#5 lore raw

PATCH 2/3 mac80211: generate mesh probe requests

In reply to Thomas Pedersen

A mesh probe request must include the mesh ID IE and a wildcard SSID IE. Add this and transpose the SSID scan list into mesh IDs for mesh interfaces.

Also allow the user to specify a mesh ID IE in the user scan IEs, since additional SSID IEs seem to be allowed.

---
 net/mac80211/tx.c   |   15 +++++++++++----
 net/mac80211/util.c |    1 +
 2 files changed, 12 insertions(+), 4 deletions(-)
net/mac80211/tx.c +11 -4
index 01dc001..9f3e9ba 100644
@@ -2622,11 +2622,18 @@ struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw,
 	memcpy(hdr->addr2, vif->addr, ETH_ALEN);
 	eth_broadcast_addr(hdr->addr3);
 
-	pos = skb_put(skb, ie_ssid_len);
-	*pos++ = WLAN_EID_SSID;
+	if (ieee80211_vif_is_mesh(vif)) {
+		pos = skb_put(skb, 2 + 2 + ssid_len);
+		*pos++ = WLAN_EID_SSID;
+		*pos++ = 0;
+		/* NOTE: mesh ID will be out of order */
+		*pos++ = WLAN_EID_MESH_ID;
+	} else {
+		pos = skb_put(skb, 2 + ssid_len);
+		*pos++ = WLAN_EID_SSID;
+	}
 	*pos++ = ssid_len;
-	if (ssid_len)
-		memcpy(pos, ssid, ssid_len);
+	memcpy(pos, ssid, ssid_len);
 	pos += ssid_len;
 
 	return skb;
net/mac80211/util.c +1 -0
index 139ad9b..aeb0f88 100644
@@ -1181,6 +1181,7 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
 	if (ie && ie_len) {
 		static const u8 before_ht[] = {
 			WLAN_EID_SSID,
+			WLAN_EID_MESH_ID,
 			WLAN_EID_SUPP_RATES,
 			WLAN_EID_REQUEST,
 			WLAN_EID_EXT_SUPP_RATES,
Signature · 1 line
1.7.10.4
maintainer
#6 lore raw

Re: [PATCH 2/3] mac80211: generate mesh probe requests

net/mac80211/tx.c struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw, · line 2629

Quoted 7 lines · Thomas Pedersen
net/mac80211/tx.c +5 -2
-	pos = skb_put(skb, ie_ssid_len);
-	*pos++ = WLAN_EID_SSID;
+	if (ieee80211_vif_is_mesh(vif)) {
+		pos = skb_put(skb, 2 + 2 + ssid_len);
+		*pos++ = WLAN_EID_SSID;
+		*pos++ = 0;
+		/* NOTE: mesh ID will be out of order */

Why put it out of order?

Also I'm not convinced that it's a good idea to translate "SSID" from the userspace API to "mesh ID" silently? Might make more sense to have those separately maybe? I mean, it seems reasonable to even think you might scan for a mesh network when you're not a mesh interface, for example?

johannes

#7 lore raw

Re: [PATCH 2/3] mac80211: generate mesh probe requests

Quoted 10 lines · Johannes Berg

net/mac80211/tx.c struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw, · line 2629

Quoted 7 lines · Thomas Pedersen
net/mac80211/tx.c +5 -2
-     pos = skb_put(skb, ie_ssid_len);
-     *pos++ = WLAN_EID_SSID;
+     if (ieee80211_vif_is_mesh(vif)) {
+             pos = skb_put(skb, 2 + 2 + ssid_len);
+             *pos++ = WLAN_EID_SSID;
+             *pos++ = 0;
+             /* NOTE: mesh ID will be out of order */
Quoted 7 lines

Why put it out of order?

Also I'm not convinced that it's a good idea to translate "SSID" from the userspace API to "mesh ID" silently? Might make more sense to have those separately maybe? I mean, it seems reasonable to even think you might scan for a mesh network when you're not a mesh interface, for example?

Yeah that makes more sense, but will obviously require more work. I'll just drop this for now.

Signature · 1 line
Thomas
#8 lore raw

Re: [PATCH 2/3] mac80211: generate mesh probe requests

In reply to Johannes Berg
Quoted 10 lines · Johannes Berg

net/mac80211/tx.c struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw, · line 2629

Quoted 7 lines · Thomas Pedersen
net/mac80211/tx.c +5 -2
-     pos = skb_put(skb, ie_ssid_len);
-     *pos++ = WLAN_EID_SSID;
+     if (ieee80211_vif_is_mesh(vif)) {
+             pos = skb_put(skb, 2 + 2 + ssid_len);
+             *pos++ = WLAN_EID_SSID;
+             *pos++ = 0;
+             /* NOTE: mesh ID will be out of order */
Quoted 7 lines

Why put it out of order?

Also I'm not convinced that it's a good idea to translate "SSID" from the userspace API to "mesh ID" silently? Might make more sense to have those separately maybe? I mean, it seems reasonable to even think you might scan for a mesh network when you're not a mesh interface, for example?

Yeah that makes more sense, but will obviously require more work. I'll just drop this for now.

Signature · 1 line
Thomas
maintainer
#9 lore raw

Re: [PATCH 2/3] mac80211: generate mesh probe requests

Quoted 13 lines · Thomas Pedersen
Quoted 12 lines · Johannes Berg

net/mac80211/tx.c struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw, · line 2629

Quoted 7 lines · Thomas Pedersen
net/mac80211/tx.c +5 -2
-     pos = skb_put(skb, ie_ssid_len);
-     *pos++ = WLAN_EID_SSID;
+     if (ieee80211_vif_is_mesh(vif)) {
+             pos = skb_put(skb, 2 + 2 + ssid_len);
+             *pos++ = WLAN_EID_SSID;
+             *pos++ = 0;
+             /* NOTE: mesh ID will be out of order */

Why put it out of order?

Quoted 8 lines
Quoted 5 lines

Also I'm not convinced that it's a good idea to translate "SSID" from the userspace API to "mesh ID" silently? Might make more sense to have those separately maybe? I mean, it seems reasonable to even think you might scan for a mesh network when you're not a mesh interface, for example?

Yeah that makes more sense, but will obviously require more work. I'll just drop this for now.

I guess the other question is if you actually want this at all. I mean, if you just do patch 1 and 3, then unless you want to actively scan for multiple networks you can just include the mesh ID in the IE parameter. Seems for many purposes that could be acceptable already. Now I'm not saying that you shouldn't put it into the kernel, there certainly could be value in that, just saying that in terms of effort that might be easier?

johannes

#10 lore raw

Re: [PATCH 2/3] mac80211: generate mesh probe requests

Quoted 23 lines · Johannes Berg
Quoted 13 lines · Thomas Pedersen
Quoted 12 lines · Johannes Berg

net/mac80211/tx.c struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw, · line 2629

Quoted 7 lines · Thomas Pedersen
net/mac80211/tx.c +5 -2
-     pos = skb_put(skb, ie_ssid_len);
-     *pos++ = WLAN_EID_SSID;
+     if (ieee80211_vif_is_mesh(vif)) {
+             pos = skb_put(skb, 2 + 2 + ssid_len);
+             *pos++ = WLAN_EID_SSID;
+             *pos++ = 0;
+             /* NOTE: mesh ID will be out of order */

Why put it out of order?

Quoted 8 lines
Quoted 5 lines

Also I'm not convinced that it's a good idea to translate "SSID" from the userspace API to "mesh ID" silently? Might make more sense to have those separately maybe? I mean, it seems reasonable to even think you might scan for a mesh network when you're not a mesh interface, for example?

Yeah that makes more sense, but will obviously require more work. I'll just drop this for now.

Quoted 7 lines

I guess the other question is if you actually want this at all. I mean, if you just do patch 1 and 3, then unless you want to actively scan for multiple networks you can just include the mesh ID in the IE parameter. Seems for many purposes that could be acceptable already. Now I'm not saying that you shouldn't put it into the kernel, there certainly could be value in that, just saying that in terms of effort that might be easier?

Yeah, allowing userspace to specify the mesh ID IEs would be easy for now.

Thanks,

Signature · 1 line
Thomas
#11 lore raw

PATCH 3/3 mac80211: generate mesh probe responses

In reply to Thomas Pedersen

Mesh interfaces will now respond to any broadcast (or matching directed mesh) probe requests with a probe response.

---
 net/mac80211/mesh.c |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++
 net/mac80211/rx.c   |    5 ++--
 2 files changed, 66 insertions(+), 2 deletions(-)
net/mac80211/mesh.c +63 -0
index e08abc0..697ebc1 100644
@@ -802,6 +802,66 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
 	sdata->u.mesh.timers_running = 0;
 }
 
+static void
+ieee80211_mesh_rx_probe_req(struct ieee80211_sub_if_data *sdata,
+			    struct ieee80211_mgmt *mgmt, size_t len)
+{
+	struct ieee80211_local *local = sdata->local;
+	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
+	struct sk_buff *presp;
+	struct beacon_data *bcn;
+	struct ieee80211_mgmt *hdr;
+	struct ieee802_11_elems elems;
+	size_t baselen;
+	u8 *pos, *end;
+
+	end = ((u8 *) mgmt) + len;
+	pos = mgmt->u.probe_req.variable;
+	baselen = (u8 *) pos - (u8 *) mgmt;
+	if (baselen > len)
+		return;
+
+	ieee802_11_parse_elems(pos, len - baselen, &elems);
+
+	/* 802.11-2012 10.1.4.3.2 */
+	if ((!ether_addr_equal(mgmt->da, sdata->vif.addr) &&
+	     !is_broadcast_ether_addr(mgmt->da)) ||
+	    elems.ssid_len != 0)
+		return;
+
+	if (elems.mesh_id_len != 0 &&
+	    (elems.mesh_id_len != ifmsh->mesh_id_len ||
+	     memcmp(elems.mesh_id, ifmsh->mesh_id, ifmsh->mesh_id_len))) {
+		mpl_dbg(sdata, "ignoring probe request for different MBSS\n");
+		return;
+	}
+
+	rcu_read_lock();
+	bcn = rcu_dereference(ifmsh->beacon);
+
+	if (!bcn)
+		goto out;
+
+	presp = dev_alloc_skb(local->tx_headroom +
+			      bcn->head_len + bcn->tail_len);
+	if (WARN_ON(!presp))
+		goto out;
+
+	skb_reserve(presp, local->tx_headroom);
+	memcpy(skb_put(presp, bcn->head_len), bcn->head, bcn->head_len);
+	memcpy(skb_put(presp, bcn->tail_len), bcn->tail, bcn->tail_len);
+	hdr = (struct ieee80211_mgmt *) presp->data;
+	hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
+					 IEEE80211_STYPE_PROBE_RESP);
+	memcpy(hdr->da, mgmt->sa, ETH_ALEN);
+	mpl_dbg(sdata, "sending probe resp. to %pM\n", hdr->da);
+	IEEE80211_SKB_CB(presp)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
+	ieee80211_tx_skb(sdata, presp);
+out:
+	rcu_read_unlock();
+	return;
+}
+
 static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
 					u16 stype,
 					struct ieee80211_mgmt *mgmt,
@@ -891,6 +951,9 @@ void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
 		ieee80211_mesh_rx_bcn_presp(sdata, stype, mgmt, skb->len,
 					    rx_status);
 		break;
+	case IEEE80211_STYPE_PROBE_REQ:
+		ieee80211_mesh_rx_probe_req(sdata, mgmt, skb->len);
+		break;
 	case IEEE80211_STYPE_ACTION:
 		ieee80211_mesh_rx_mgmt_action(sdata, mgmt, skb->len, rx_status);
 		break;
net/mac80211/rx.c +3 -2
index a190895..226ae06 100644
@@ -2677,8 +2677,9 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
 			return RX_DROP_MONITOR;
 		break;
 	case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ):
-		/* process only for ibss */
-		if (sdata->vif.type != NL80211_IFTYPE_ADHOC)
+		/* process only for ibss and mesh */
+		if (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
+		    sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
 			return RX_DROP_MONITOR;
 		break;
 	default:
Signature · 1 line
1.7.10.4