aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/ibss.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-05-10 06:32:47 -0400
committerJohannes Berg <johannes.berg@intel.com>2013-05-24 18:02:16 -0400
commit8d61ffa5e01c5f676431d12caba17db164a48a86 (patch)
treec3df0dc13fdc8d2327712db10c1c654f428f11a3 /net/mac80211/ibss.c
parent5fe231e873729fa2f57cdc417d5c1f80871e2d7d (diff)
cfg80211/mac80211: use cfg80211 wdev mutex in mac80211
Using separate locks in cfg80211 and mac80211 has always caused issues, for example having to unlock in places in mac80211 to call cfg80211, which even needed a framework to make cfg80211 calls after some functions returned etc. Additionally, I suspect some issues people have reported with the cfg80211 state getting confused could be due to such issues, when cfg80211 is asking mac80211 to change state but mac80211 is in the process of telling cfg80211 that the state changed (in another way.) Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/ibss.c')
-rw-r--r--net/mac80211/ibss.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 956ba6316da5..caa4b4f7f6e4 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -54,7 +54,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
54 struct beacon_data *presp; 54 struct beacon_data *presp;
55 int frame_len; 55 int frame_len;
56 56
57 lockdep_assert_held(&ifibss->mtx); 57 sdata_assert_lock(sdata);
58 58
59 /* Reset own TSF to allow time synchronization work. */ 59 /* Reset own TSF to allow time synchronization work. */
60 drv_reset_tsf(local, sdata); 60 drv_reset_tsf(local, sdata);
@@ -74,7 +74,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
74 } 74 }
75 75
76 presp = rcu_dereference_protected(ifibss->presp, 76 presp = rcu_dereference_protected(ifibss->presp,
77 lockdep_is_held(&ifibss->mtx)); 77 lockdep_is_held(&sdata->wdev.mtx));
78 rcu_assign_pointer(ifibss->presp, NULL); 78 rcu_assign_pointer(ifibss->presp, NULL);
79 if (presp) 79 if (presp)
80 kfree_rcu(presp, rcu_head); 80 kfree_rcu(presp, rcu_head);
@@ -263,7 +263,7 @@ static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
263 const struct cfg80211_bss_ies *ies; 263 const struct cfg80211_bss_ies *ies;
264 u64 tsf; 264 u64 tsf;
265 265
266 lockdep_assert_held(&sdata->u.ibss.mtx); 266 sdata_assert_lock(sdata);
267 267
268 if (beacon_int < 10) 268 if (beacon_int < 10)
269 beacon_int = 10; 269 beacon_int = 10;
@@ -410,7 +410,7 @@ static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata,
410 struct sta_info *sta; 410 struct sta_info *sta;
411 u8 deauth_frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; 411 u8 deauth_frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
412 412
413 lockdep_assert_held(&sdata->u.ibss.mtx); 413 sdata_assert_lock(sdata);
414 414
415 if (len < 24 + 6) 415 if (len < 24 + 6)
416 return; 416 return;
@@ -677,7 +677,7 @@ static int ieee80211_sta_active_ibss(struct ieee80211_sub_if_data *sdata)
677 int active = 0; 677 int active = 0;
678 struct sta_info *sta; 678 struct sta_info *sta;
679 679
680 lockdep_assert_held(&sdata->u.ibss.mtx); 680 sdata_assert_lock(sdata);
681 681
682 rcu_read_lock(); 682 rcu_read_lock();
683 683
@@ -703,7 +703,7 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata)
703{ 703{
704 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 704 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
705 705
706 lockdep_assert_held(&ifibss->mtx); 706 sdata_assert_lock(sdata);
707 707
708 mod_timer(&ifibss->timer, 708 mod_timer(&ifibss->timer,
709 round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL)); 709 round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL));
@@ -734,7 +734,7 @@ static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
734 u16 capability; 734 u16 capability;
735 int i; 735 int i;
736 736
737 lockdep_assert_held(&ifibss->mtx); 737 sdata_assert_lock(sdata);
738 738
739 if (ifibss->fixed_bssid) { 739 if (ifibss->fixed_bssid) {
740 memcpy(bssid, ifibss->bssid, ETH_ALEN); 740 memcpy(bssid, ifibss->bssid, ETH_ALEN);
@@ -777,7 +777,7 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
777 int active_ibss; 777 int active_ibss;
778 u16 capability; 778 u16 capability;
779 779
780 lockdep_assert_held(&ifibss->mtx); 780 sdata_assert_lock(sdata);
781 781
782 active_ibss = ieee80211_sta_active_ibss(sdata); 782 active_ibss = ieee80211_sta_active_ibss(sdata);
783 ibss_dbg(sdata, "sta_find_ibss (active_ibss=%d)\n", active_ibss); 783 ibss_dbg(sdata, "sta_find_ibss (active_ibss=%d)\n", active_ibss);
@@ -847,10 +847,10 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
847 struct beacon_data *presp; 847 struct beacon_data *presp;
848 u8 *pos, *end; 848 u8 *pos, *end;
849 849
850 lockdep_assert_held(&ifibss->mtx); 850 sdata_assert_lock(sdata);
851 851
852 presp = rcu_dereference_protected(ifibss->presp, 852 presp = rcu_dereference_protected(ifibss->presp,
853 lockdep_is_held(&ifibss->mtx)); 853 lockdep_is_held(&sdata->wdev.mtx));
854 854
855 if (ifibss->state != IEEE80211_IBSS_MLME_JOINED || 855 if (ifibss->state != IEEE80211_IBSS_MLME_JOINED ||
856 len < 24 + 2 || !presp) 856 len < 24 + 2 || !presp)
@@ -934,7 +934,7 @@ void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
934 mgmt = (struct ieee80211_mgmt *) skb->data; 934 mgmt = (struct ieee80211_mgmt *) skb->data;
935 fc = le16_to_cpu(mgmt->frame_control); 935 fc = le16_to_cpu(mgmt->frame_control);
936 936
937 mutex_lock(&sdata->u.ibss.mtx); 937 sdata_lock(sdata);
938 938
939 if (!sdata->u.ibss.ssid_len) 939 if (!sdata->u.ibss.ssid_len)
940 goto mgmt_out; /* not ready to merge yet */ 940 goto mgmt_out; /* not ready to merge yet */
@@ -957,7 +957,7 @@ void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
957 } 957 }
958 958
959 mgmt_out: 959 mgmt_out:
960 mutex_unlock(&sdata->u.ibss.mtx); 960 sdata_unlock(sdata);
961} 961}
962 962
963void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata) 963void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata)
@@ -965,7 +965,7 @@ void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata)
965 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 965 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
966 struct sta_info *sta; 966 struct sta_info *sta;
967 967
968 mutex_lock(&ifibss->mtx); 968 sdata_lock(sdata);
969 969
970 /* 970 /*
971 * Work could be scheduled after scan or similar 971 * Work could be scheduled after scan or similar
@@ -1001,7 +1001,7 @@ void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata)
1001 } 1001 }
1002 1002
1003 out: 1003 out:
1004 mutex_unlock(&ifibss->mtx); 1004 sdata_unlock(sdata);
1005} 1005}
1006 1006
1007static void ieee80211_ibss_timer(unsigned long data) 1007static void ieee80211_ibss_timer(unsigned long data)
@@ -1018,7 +1018,6 @@ void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata)
1018 1018
1019 setup_timer(&ifibss->timer, ieee80211_ibss_timer, 1019 setup_timer(&ifibss->timer, ieee80211_ibss_timer,
1020 (unsigned long) sdata); 1020 (unsigned long) sdata);
1021 mutex_init(&ifibss->mtx);
1022 INIT_LIST_HEAD(&ifibss->incomplete_stations); 1021 INIT_LIST_HEAD(&ifibss->incomplete_stations);
1023 spin_lock_init(&ifibss->incomplete_lock); 1022 spin_lock_init(&ifibss->incomplete_lock);
1024} 1023}
@@ -1045,8 +1044,6 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1045{ 1044{
1046 u32 changed = 0; 1045 u32 changed = 0;
1047 1046
1048 mutex_lock(&sdata->u.ibss.mtx);
1049
1050 if (params->bssid) { 1047 if (params->bssid) {
1051 memcpy(sdata->u.ibss.bssid, params->bssid, ETH_ALEN); 1048 memcpy(sdata->u.ibss.bssid, params->bssid, ETH_ALEN);
1052 sdata->u.ibss.fixed_bssid = true; 1049 sdata->u.ibss.fixed_bssid = true;
@@ -1079,8 +1076,6 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1079 memcpy(sdata->u.ibss.ssid, params->ssid, params->ssid_len); 1076 memcpy(sdata->u.ibss.ssid, params->ssid, params->ssid_len);
1080 sdata->u.ibss.ssid_len = params->ssid_len; 1077 sdata->u.ibss.ssid_len = params->ssid_len;
1081 1078
1082 mutex_unlock(&sdata->u.ibss.mtx);
1083
1084 /* 1079 /*
1085 * 802.11n-2009 9.13.3.1: In an IBSS, the HT Protection field is 1080 * 802.11n-2009 9.13.3.1: In an IBSS, the HT Protection field is
1086 * reserved, but an HT STA shall protect HT transmissions as though 1081 * reserved, but an HT STA shall protect HT transmissions as though
@@ -1116,8 +1111,6 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata)
1116 struct sta_info *sta; 1111 struct sta_info *sta;
1117 struct beacon_data *presp; 1112 struct beacon_data *presp;
1118 1113
1119 mutex_lock(&sdata->u.ibss.mtx);
1120
1121 active_ibss = ieee80211_sta_active_ibss(sdata); 1114 active_ibss = ieee80211_sta_active_ibss(sdata);
1122 1115
1123 if (!active_ibss && !is_zero_ether_addr(ifibss->bssid)) { 1116 if (!active_ibss && !is_zero_ether_addr(ifibss->bssid)) {
@@ -1161,7 +1154,7 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata)
1161 /* remove beacon */ 1154 /* remove beacon */
1162 kfree(sdata->u.ibss.ie); 1155 kfree(sdata->u.ibss.ie);
1163 presp = rcu_dereference_protected(ifibss->presp, 1156 presp = rcu_dereference_protected(ifibss->presp,
1164 lockdep_is_held(&sdata->u.ibss.mtx)); 1157 lockdep_is_held(&sdata->wdev.mtx));
1165 RCU_INIT_POINTER(sdata->u.ibss.presp, NULL); 1158 RCU_INIT_POINTER(sdata->u.ibss.presp, NULL);
1166 sdata->vif.bss_conf.ibss_joined = false; 1159 sdata->vif.bss_conf.ibss_joined = false;
1167 sdata->vif.bss_conf.ibss_creator = false; 1160 sdata->vif.bss_conf.ibss_creator = false;
@@ -1177,7 +1170,5 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata)
1177 1170
1178 del_timer_sync(&sdata->u.ibss.timer); 1171 del_timer_sync(&sdata->u.ibss.timer);
1179 1172
1180 mutex_unlock(&sdata->u.ibss.mtx);
1181
1182 return 0; 1173 return 0;
1183} 1174}