linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] mac80211: improve cleanup when leaving mesh
@ 2012-08-03 19:21 Thomas Pedersen
  2012-08-03 19:21 ` [PATCH v2 2/4] mac80211: remove ieee80211_clean_sdata() Thomas Pedersen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Thomas Pedersen @ 2012-08-03 19:21 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, devel, Thomas Pedersen

It is not necessary to stop the mesh beacon in the mac80211 ndo_stop
handler, since cfg80211 has already left the mesh on NETDEV_GOING_DOWN
notification.

Also some improvements to ieee80211_stop_mesh():

 - flush mpath entries.
 - flush sta entries per-sdata so we don't remove entries belonging to
   other vifs on the same hw.

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>

---
v2: don't leave the mesh twice :) (Johannes)

 net/mac80211/iface.c |    8 --------
 net/mac80211/mesh.c  |    6 +++++-
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index bfb57dc..b6c5a92 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -771,14 +771,6 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
 		skb_queue_purge(&sdata->skb_queue);
 
 		/*
-		 * Disable beaconing here for mesh only, AP and IBSS
-		 * are already taken care of.
-		 */
-		if (sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
-			ieee80211_bss_info_change_notify(sdata,
-				BSS_CHANGED_BEACON_ENABLED);
-
-		/*
 		 * Free all remaining keys, there shouldn't be any,
 		 * except maybe group keys in AP more or WDS?
 		 */
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 8557235..a01559d 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -616,9 +616,13 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
 	struct ieee80211_local *local = sdata->local;
 	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
 
+	/* stop the beacon */
 	ifmsh->mesh_id_len = 0;
 	ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
-	sta_info_flush(local, NULL);
+
+	/* flush STAs and mpaths on this iface */
+	sta_info_flush(sdata->local, sdata);
+	mesh_path_flush_by_iface(sdata);
 
 	del_timer_sync(&sdata->u.mesh.housekeeping_timer);
 	del_timer_sync(&sdata->u.mesh.mesh_path_root_timer);
-- 
1.7.5.4


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

* [PATCH v2 2/4] mac80211: remove ieee80211_clean_sdata()
  2012-08-03 19:21 [PATCH v2 1/4] mac80211: improve cleanup when leaving mesh Thomas Pedersen
@ 2012-08-03 19:21 ` Thomas Pedersen
  2012-08-03 19:21 ` [PATCH v2 3/4] mac80211: don't request ack for peering close Thomas Pedersen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Thomas Pedersen @ 2012-08-03 19:21 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, devel, Thomas Pedersen

This function was only used by mesh, and not really needed since any
interface-specific cleanup already happens in the netdev handlers.

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
---
 net/mac80211/iface.c |   17 -----------------
 1 files changed, 0 insertions(+), 17 deletions(-)

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index b6c5a92..22e2923 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1148,18 +1148,6 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
 	ieee80211_debugfs_add_netdev(sdata);
 }
 
-static void ieee80211_clean_sdata(struct ieee80211_sub_if_data *sdata)
-{
-	switch (sdata->vif.type) {
-	case NL80211_IFTYPE_MESH_POINT:
-		mesh_path_flush_by_iface(sdata);
-		break;
-
-	default:
-		break;
-	}
-}
-
 static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata,
 					   enum nl80211_iftype type)
 {
@@ -1495,9 +1483,6 @@ void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata)
 	list_del_rcu(&sdata->list);
 	mutex_unlock(&sdata->local->iflist_mtx);
 
-	/* clean up type-dependent data */
-	ieee80211_clean_sdata(sdata);
-
 	synchronize_rcu();
 	unregister_netdevice(sdata->dev);
 }
@@ -1517,8 +1502,6 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)
 	list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
 		list_del(&sdata->list);
 
-		ieee80211_clean_sdata(sdata);
-
 		unregister_netdevice_queue(sdata->dev, &unreg_list);
 	}
 	mutex_unlock(&local->iflist_mtx);
-- 
1.7.5.4


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

* [PATCH v2 3/4] mac80211: don't request ack for peering close
  2012-08-03 19:21 [PATCH v2 1/4] mac80211: improve cleanup when leaving mesh Thomas Pedersen
  2012-08-03 19:21 ` [PATCH v2 2/4] mac80211: remove ieee80211_clean_sdata() Thomas Pedersen
@ 2012-08-03 19:21 ` Thomas Pedersen
  2012-08-03 19:21 ` [PATCH v2 4/4] mac80211: skb leak in mesh_plink_frame_tx() Thomas Pedersen
  2012-08-03 19:31 ` [PATCH v2 1/4] mac80211: improve cleanup when leaving mesh Johannes Berg
  3 siblings, 0 replies; 5+ messages in thread
From: Thomas Pedersen @ 2012-08-03 19:21 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, devel, Thomas Pedersen

It doesn't make a lot of sense to wait for an ack in response to a
peering close frame since either peer in this exchange could be going
down.

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
---
 net/mac80211/mesh_plink.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index af671b9..a5300ef 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -217,6 +217,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
 		u8 *da, __le16 llid, __le16 plid, __le16 reason) {
 	struct ieee80211_local *local = sdata->local;
 	struct sk_buff *skb;
+	struct ieee80211_tx_info *info;
 	struct ieee80211_mgmt *mgmt;
 	bool include_plid = false;
 	u16 peering_proto = 0;
@@ -238,6 +239,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
 			    sdata->u.mesh.ie_len);
 	if (!skb)
 		return -1;
+	info = IEEE80211_SKB_CB(skb);
 	skb_reserve(skb, local->tx_headroom);
 	mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
 	memset(mgmt, 0, hdr_len);
@@ -265,6 +267,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
 		    mesh_add_meshconf_ie(skb, sdata))
 			return -1;
 	} else {	/* WLAN_SP_MESH_PEERING_CLOSE */
+		info->flags |= IEEE80211_TX_CTL_NO_ACK;
 		if (mesh_add_meshid_ie(skb, sdata))
 			return -1;
 	}
-- 
1.7.5.4


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

* [PATCH v2 4/4] mac80211: skb leak in mesh_plink_frame_tx()
  2012-08-03 19:21 [PATCH v2 1/4] mac80211: improve cleanup when leaving mesh Thomas Pedersen
  2012-08-03 19:21 ` [PATCH v2 2/4] mac80211: remove ieee80211_clean_sdata() Thomas Pedersen
  2012-08-03 19:21 ` [PATCH v2 3/4] mac80211: don't request ack for peering close Thomas Pedersen
@ 2012-08-03 19:21 ` Thomas Pedersen
  2012-08-03 19:31 ` [PATCH v2 1/4] mac80211: improve cleanup when leaving mesh Johannes Berg
  3 siblings, 0 replies; 5+ messages in thread
From: Thomas Pedersen @ 2012-08-03 19:21 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, devel, Thomas Pedersen

Although adding an IE is almost guaranteed to succeed since we already
accounted for its length while allocating the skb, we should still free
the skb in case of failure.

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
---
 net/mac80211/mesh_plink.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index a5300ef..7e1c924 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -224,6 +224,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
 	u8 *pos, ie_len = 4;
 	int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.self_prot) +
 		      sizeof(mgmt->u.action.u.self_prot);
+	int err = -ENOMEM;
 
 	skb = dev_alloc_skb(local->tx_headroom +
 			    hdr_len +
@@ -265,11 +266,11 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
 		    mesh_add_rsn_ie(skb, sdata) ||
 		    mesh_add_meshid_ie(skb, sdata) ||
 		    mesh_add_meshconf_ie(skb, sdata))
-			return -1;
+			goto free;
 	} else {	/* WLAN_SP_MESH_PEERING_CLOSE */
 		info->flags |= IEEE80211_TX_CTL_NO_ACK;
 		if (mesh_add_meshid_ie(skb, sdata))
-			return -1;
+			goto free;
 	}
 
 	/* Add Mesh Peering Management element */
@@ -288,11 +289,12 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
 		ie_len += 2;	/* reason code */
 		break;
 	default:
-		return -EINVAL;
+		err = -EINVAL;
+		goto free;
 	}
 
 	if (WARN_ON(skb_tailroom(skb) < 2 + ie_len))
-		return -ENOMEM;
+		goto free;
 
 	pos = skb_put(skb, 2 + ie_len);
 	*pos++ = WLAN_EID_PEER_MGMT;
@@ -313,14 +315,17 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
 	if (action != WLAN_SP_MESH_PEERING_CLOSE) {
 		if (mesh_add_ht_cap_ie(skb, sdata) ||
 		    mesh_add_ht_oper_ie(skb, sdata))
-			return -1;
+			goto free;
 	}
 
 	if (mesh_add_vendor_ies(skb, sdata))
-		return -1;
+		goto free;
 
 	ieee80211_tx_skb(sdata, skb);
 	return 0;
+free:
+	kfree_skb(skb);
+	return err;
 }
 
 /**
-- 
1.7.5.4


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

* Re: [PATCH v2 1/4] mac80211: improve cleanup when leaving mesh
  2012-08-03 19:21 [PATCH v2 1/4] mac80211: improve cleanup when leaving mesh Thomas Pedersen
                   ` (2 preceding siblings ...)
  2012-08-03 19:21 ` [PATCH v2 4/4] mac80211: skb leak in mesh_plink_frame_tx() Thomas Pedersen
@ 2012-08-03 19:31 ` Johannes Berg
  3 siblings, 0 replies; 5+ messages in thread
From: Johannes Berg @ 2012-08-03 19:31 UTC (permalink / raw)
  To: Thomas Pedersen; +Cc: linux-wireless, devel

On Fri, 2012-08-03 at 12:21 -0700, Thomas Pedersen wrote:
> It is not necessary to stop the mesh beacon in the mac80211 ndo_stop
> handler, since cfg80211 has already left the mesh on NETDEV_GOING_DOWN
> notification.

Applied all, thanks.

johannes


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

end of thread, other threads:[~2012-08-03 19:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-03 19:21 [PATCH v2 1/4] mac80211: improve cleanup when leaving mesh Thomas Pedersen
2012-08-03 19:21 ` [PATCH v2 2/4] mac80211: remove ieee80211_clean_sdata() Thomas Pedersen
2012-08-03 19:21 ` [PATCH v2 3/4] mac80211: don't request ack for peering close Thomas Pedersen
2012-08-03 19:21 ` [PATCH v2 4/4] mac80211: skb leak in mesh_plink_frame_tx() Thomas Pedersen
2012-08-03 19:31 ` [PATCH v2 1/4] mac80211: improve cleanup when leaving mesh Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).