mac80211: improve cleanup when leaving mesh
PATCH v2 1/4 mac80211: improve cleanup when leaving mesh
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.
---
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(-)
net/mac80211/iface.c +0 -8
@@ -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? */
net/mac80211/mesh.c +5 -1
@@ -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);
Signature · 1 line
1.7.5.4
PATCH v2 2/4 mac80211: remove ieee80211_clean_sdata()
This function was only used by mesh, and not really needed since any interface-specific cleanup already happens in the netdev handlers.
--- net/mac80211/iface.c | 17 ----------------- 1 files changed, 0 insertions(+), 17 deletions(-)
net/mac80211/iface.c +0 -17
@@ -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);
Signature · 1 line
1.7.5.4
PATCH v2 3/4 mac80211: don't request ack for peering close
In reply to Thomas PedersenIt 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.
--- net/mac80211/mesh_plink.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
net/mac80211/mesh_plink.c +3 -0
@@ -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 ; }
Signature · 1 line
1.7.5.4
PATCH v2 4/4 mac80211: skb leak in mesh_plink_frame_tx()
In reply to Thomas PedersenAlthough 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.
--- net/mac80211/mesh_plink.c | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-)
net/mac80211/mesh_plink.c +11 -6
@@ -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; }/**
Signature · 1 line
1.7.5.4
Quoted 3 lines · Thomas Pedersen
It is not necessary to stop the mesh beacon in the mac80211
ndo_stophandler, since cfg80211 has already left the mesh onNETDEV_GOING_DOWNnotification.
Applied all, thanks.
johannes