aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-01-21 09:13:48 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 16:01:09 -0500
commit881d948c23442173a011f1adcfe4c95bf7f27515 (patch)
tree3d7e6a4bf23b960cf45a4d2c5734578168ce0424
parent369391db1aabd089cefaadaabb6d9fc82e78b0a7 (diff)
wireless: restrict to 32 legacy rates
Since the standards only define 12 legacy rates, 32 is certainly a sane upper limit and we don't need to use u64 everywhere. Add sanity checking that no more than 32 rates are registered and change the variables to u32 throughout. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/b43/main.c2
-rw-r--r--drivers/net/wireless/b43legacy/main.c2
-rw-r--r--drivers/net/wireless/p54/p54.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h2
-rw-r--r--include/net/mac80211.h4
-rw-r--r--include/net/wireless.h2
-rw-r--r--net/mac80211/ieee80211_i.h6
-rw-r--r--net/mac80211/mesh.c2
-rw-r--r--net/mac80211/mesh.h2
-rw-r--r--net/mac80211/mesh_plink.c6
-rw-r--r--net/mac80211/mlme.c16
-rw-r--r--net/mac80211/util.c4
-rw-r--r--net/wireless/core.c12
-rw-r--r--net/wireless/util.c2
14 files changed, 35 insertions, 29 deletions
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 8bb6659c0b3f..675a73a98072 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -3398,7 +3398,7 @@ out_unlock_mutex:
3398 return err; 3398 return err;
3399} 3399}
3400 3400
3401static void b43_update_basic_rates(struct b43_wldev *dev, u64 brates) 3401static void b43_update_basic_rates(struct b43_wldev *dev, u32 brates)
3402{ 3402{
3403 struct ieee80211_supported_band *sband = 3403 struct ieee80211_supported_band *sband =
3404 dev->wl->hw->wiphy->bands[b43_current_band(dev->wl)]; 3404 dev->wl->hw->wiphy->bands[b43_current_band(dev->wl)];
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index fb996c27a19b..879edc786713 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -2650,7 +2650,7 @@ out_unlock_mutex:
2650 return err; 2650 return err;
2651} 2651}
2652 2652
2653static void b43legacy_update_basic_rates(struct b43legacy_wldev *dev, u64 brates) 2653static void b43legacy_update_basic_rates(struct b43legacy_wldev *dev, u32 brates)
2654{ 2654{
2655 struct ieee80211_supported_band *sband = 2655 struct ieee80211_supported_band *sband =
2656 dev->wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ]; 2656 dev->wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ];
diff --git a/drivers/net/wireless/p54/p54.h b/drivers/net/wireless/p54/p54.h
index 64492feca9b2..94c3acd1fcaf 100644
--- a/drivers/net/wireless/p54/p54.h
+++ b/drivers/net/wireless/p54/p54.h
@@ -144,7 +144,7 @@ struct p54_common {
144 unsigned int output_power; 144 unsigned int output_power;
145 u32 tsf_low32; 145 u32 tsf_low32;
146 u32 tsf_high32; 146 u32 tsf_high32;
147 u64 basic_rate_mask; 147 u32 basic_rate_mask;
148 u16 wakeup_timer; 148 u16 wakeup_timer;
149 u16 aid; 149 u16 aid;
150 struct ieee80211_tx_queue_stats tx_stats[8]; 150 struct ieee80211_tx_queue_stats tx_stats[8];
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index cc56637e73b5..46918deceda1 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -396,7 +396,7 @@ struct rt2x00lib_erp {
396 int ack_timeout; 396 int ack_timeout;
397 int ack_consume_time; 397 int ack_consume_time;
398 398
399 u64 basic_rates; 399 u32 basic_rates;
400 400
401 int slot_time; 401 int slot_time;
402 402
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index ef42559694f1..c76484009baa 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -207,7 +207,7 @@ struct ieee80211_bss_conf {
207 u16 beacon_int; 207 u16 beacon_int;
208 u16 assoc_capability; 208 u16 assoc_capability;
209 u64 timestamp; 209 u64 timestamp;
210 u64 basic_rates; 210 u32 basic_rates;
211 struct ieee80211_bss_ht_conf ht; 211 struct ieee80211_bss_ht_conf ht;
212}; 212};
213 213
@@ -761,7 +761,7 @@ enum set_key_cmd {
761 * sizeof(void *), size is determined in hw information. 761 * sizeof(void *), size is determined in hw information.
762 */ 762 */
763struct ieee80211_sta { 763struct ieee80211_sta {
764 u64 supp_rates[IEEE80211_NUM_BANDS]; 764 u32 supp_rates[IEEE80211_NUM_BANDS];
765 u8 addr[ETH_ALEN]; 765 u8 addr[ETH_ALEN];
766 u16 aid; 766 u16 aid;
767 struct ieee80211_sta_ht_cap ht_cap; 767 struct ieee80211_sta_ht_cap ht_cap;
diff --git a/include/net/wireless.h b/include/net/wireless.h
index 9e73aae40c5d..6c5b08204232 100644
--- a/include/net/wireless.h
+++ b/include/net/wireless.h
@@ -367,7 +367,7 @@ ieee80211_get_channel(struct wiphy *wiphy, int freq)
367 */ 367 */
368struct ieee80211_rate * 368struct ieee80211_rate *
369ieee80211_get_response_rate(struct ieee80211_supported_band *sband, 369ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
370 u64 basic_rates, int bitrate); 370 u32 basic_rates, int bitrate);
371 371
372/** 372/**
373 * regulatory_hint - driver hint to the wireless core a regulatory domain 373 * regulatory_hint - driver hint to the wireless core a regulatory domain
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index a8c72742a8b1..70366efc792e 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -909,11 +909,11 @@ int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid);
909void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata, 909void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata,
910 struct ieee80211_if_sta *ifsta); 910 struct ieee80211_if_sta *ifsta);
911struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, 911struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
912 u8 *bssid, u8 *addr, u64 supp_rates); 912 u8 *bssid, u8 *addr, u32 supp_rates);
913int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason); 913int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason);
914int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason); 914int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason);
915u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); 915u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
916u64 ieee80211_sta_get_rates(struct ieee80211_local *local, 916u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
917 struct ieee802_11_elems *elems, 917 struct ieee802_11_elems *elems,
918 enum ieee80211_band band); 918 enum ieee80211_band band);
919void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 919void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
@@ -1026,7 +1026,7 @@ void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
1026void ieee802_11_parse_elems(u8 *start, size_t len, 1026void ieee802_11_parse_elems(u8 *start, size_t len,
1027 struct ieee802_11_elems *elems); 1027 struct ieee802_11_elems *elems);
1028int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freq); 1028int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freq);
1029u64 ieee80211_mandatory_rates(struct ieee80211_local *local, 1029u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
1030 enum ieee80211_band band); 1030 enum ieee80211_band band);
1031 1031
1032void ieee80211_dynamic_ps_enable_work(struct work_struct *work); 1032void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 82f568e94365..2d573f8470d0 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -476,7 +476,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
476 struct ieee80211_local *local = sdata->local; 476 struct ieee80211_local *local = sdata->local;
477 struct ieee802_11_elems elems; 477 struct ieee802_11_elems elems;
478 struct ieee80211_channel *channel; 478 struct ieee80211_channel *channel;
479 u64 supp_rates = 0; 479 u32 supp_rates = 0;
480 size_t baselen; 480 size_t baselen;
481 int freq; 481 int freq;
482 enum ieee80211_band band = rx_status->band; 482 enum ieee80211_band band = rx_status->band;
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index f1196f5c3efe..9e064ee98ee0 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -236,7 +236,7 @@ void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
236 struct ieee80211_mgmt *mgmt, size_t len); 236 struct ieee80211_mgmt *mgmt, size_t len);
237int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata); 237int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata);
238/* Mesh plinks */ 238/* Mesh plinks */
239void mesh_neighbour_update(u8 *hw_addr, u64 rates, 239void mesh_neighbour_update(u8 *hw_addr, u32 rates,
240 struct ieee80211_sub_if_data *sdata, bool add); 240 struct ieee80211_sub_if_data *sdata, bool add);
241bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie); 241bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
242void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata); 242void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index c140a1b71a5e..a8bbdeca013a 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -93,7 +93,7 @@ static inline void mesh_plink_fsm_restart(struct sta_info *sta)
93 * on it in the lifecycle management section! 93 * on it in the lifecycle management section!
94 */ 94 */
95static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata, 95static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
96 u8 *hw_addr, u64 rates) 96 u8 *hw_addr, u32 rates)
97{ 97{
98 struct ieee80211_local *local = sdata->local; 98 struct ieee80211_local *local = sdata->local;
99 struct sta_info *sta; 99 struct sta_info *sta;
@@ -222,7 +222,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
222 return 0; 222 return 0;
223} 223}
224 224
225void mesh_neighbour_update(u8 *hw_addr, u64 rates, struct ieee80211_sub_if_data *sdata, 225void mesh_neighbour_update(u8 *hw_addr, u32 rates, struct ieee80211_sub_if_data *sdata,
226 bool peer_accepting_plinks) 226 bool peer_accepting_plinks)
227{ 227{
228 struct ieee80211_local *local = sdata->local; 228 struct ieee80211_local *local = sdata->local;
@@ -447,7 +447,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
447 spin_lock_bh(&sta->lock); 447 spin_lock_bh(&sta->lock);
448 } else if (!sta) { 448 } else if (!sta) {
449 /* ftype == PLINK_OPEN */ 449 /* ftype == PLINK_OPEN */
450 u64 rates; 450 u32 rates;
451 if (!mesh_plink_free_count(sdata)) { 451 if (!mesh_plink_free_count(sdata)) {
452 mpl_dbg("Mesh plink error: no more free plinks\n"); 452 mpl_dbg("Mesh plink error: no more free plinks\n");
453 rcu_read_unlock(); 453 rcu_read_unlock();
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index b9e4b93089c4..9852da54f5e7 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -73,7 +73,7 @@ static u8 *ieee80211_bss_get_ie(struct ieee80211_bss *bss, u8 ie)
73 73
74static int ieee80211_compatible_rates(struct ieee80211_bss *bss, 74static int ieee80211_compatible_rates(struct ieee80211_bss *bss,
75 struct ieee80211_supported_band *sband, 75 struct ieee80211_supported_band *sband,
76 u64 *rates) 76 u32 *rates)
77{ 77{
78 int i, j, count; 78 int i, j, count;
79 *rates = 0; 79 *rates = 0;
@@ -93,14 +93,14 @@ static int ieee80211_compatible_rates(struct ieee80211_bss *bss,
93} 93}
94 94
95/* also used by mesh code */ 95/* also used by mesh code */
96u64 ieee80211_sta_get_rates(struct ieee80211_local *local, 96u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
97 struct ieee802_11_elems *elems, 97 struct ieee802_11_elems *elems,
98 enum ieee80211_band band) 98 enum ieee80211_band band)
99{ 99{
100 struct ieee80211_supported_band *sband; 100 struct ieee80211_supported_band *sband;
101 struct ieee80211_rate *bitrates; 101 struct ieee80211_rate *bitrates;
102 size_t num_rates; 102 size_t num_rates;
103 u64 supp_rates; 103 u32 supp_rates;
104 int i, j; 104 int i, j;
105 sband = local->hw.wiphy->bands[band]; 105 sband = local->hw.wiphy->bands[band];
106 106
@@ -253,7 +253,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
253 struct ieee80211_bss *bss; 253 struct ieee80211_bss *bss;
254 int wmm = 0; 254 int wmm = 0;
255 struct ieee80211_supported_band *sband; 255 struct ieee80211_supported_band *sband;
256 u64 rates = 0; 256 u32 rates = 0;
257 size_t e_ies_len; 257 size_t e_ies_len;
258 258
259 if (ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) { 259 if (ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) {
@@ -1282,7 +1282,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1282 struct ieee80211_local *local = sdata->local; 1282 struct ieee80211_local *local = sdata->local;
1283 struct ieee80211_supported_band *sband; 1283 struct ieee80211_supported_band *sband;
1284 struct sta_info *sta; 1284 struct sta_info *sta;
1285 u64 rates, basic_rates; 1285 u32 rates, basic_rates;
1286 u16 capab_info, status_code, aid; 1286 u16 capab_info, status_code, aid;
1287 struct ieee802_11_elems elems; 1287 struct ieee802_11_elems elems;
1288 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; 1288 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
@@ -1639,7 +1639,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1639 struct sta_info *sta; 1639 struct sta_info *sta;
1640 struct ieee80211_channel *channel; 1640 struct ieee80211_channel *channel;
1641 u64 beacon_timestamp, rx_timestamp; 1641 u64 beacon_timestamp, rx_timestamp;
1642 u64 supp_rates = 0; 1642 u32 supp_rates = 0;
1643 enum ieee80211_band band = rx_status->band; 1643 enum ieee80211_band band = rx_status->band;
1644 1644
1645 if (elems->ds_params && elems->ds_params_len == 1) 1645 if (elems->ds_params && elems->ds_params_len == 1)
@@ -1660,7 +1660,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1660 1660
1661 sta = sta_info_get(local, mgmt->sa); 1661 sta = sta_info_get(local, mgmt->sa);
1662 if (sta) { 1662 if (sta) {
1663 u64 prev_rates; 1663 u32 prev_rates;
1664 1664
1665 prev_rates = sta->sta.supp_rates[band]; 1665 prev_rates = sta->sta.supp_rates[band];
1666 /* make sure mandatory rates are always added */ 1666 /* make sure mandatory rates are always added */
@@ -2526,7 +2526,7 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
2526 * must be callable in atomic context. 2526 * must be callable in atomic context.
2527 */ 2527 */
2528struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, 2528struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
2529 u8 *bssid,u8 *addr, u64 supp_rates) 2529 u8 *bssid,u8 *addr, u32 supp_rates)
2530{ 2530{
2531 struct ieee80211_local *local = sdata->local; 2531 struct ieee80211_local *local = sdata->local;
2532 struct sta_info *sta; 2532 struct sta_info *sta;
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 3f559e3d0a7c..ede96c4fea2e 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -731,12 +731,12 @@ int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freqMHz)
731 return ret; 731 return ret;
732} 732}
733 733
734u64 ieee80211_mandatory_rates(struct ieee80211_local *local, 734u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
735 enum ieee80211_band band) 735 enum ieee80211_band band)
736{ 736{
737 struct ieee80211_supported_band *sband; 737 struct ieee80211_supported_band *sband;
738 struct ieee80211_rate *bitrates; 738 struct ieee80211_rate *bitrates;
739 u64 mandatory_rates; 739 u32 mandatory_rates;
740 enum ieee80211_rate_flags mandatory_flag; 740 enum ieee80211_rate_flags mandatory_flag;
741 int i; 741 int i;
742 742
diff --git a/net/wireless/core.c b/net/wireless/core.c
index b96fc0c3f1c4..125226476089 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -273,10 +273,16 @@ int wiphy_register(struct wiphy *wiphy)
273 273
274 sband->band = band; 274 sband->band = band;
275 275
276 if (!sband->n_channels || !sband->n_bitrates) { 276 if (WARN_ON(!sband->n_channels || !sband->n_bitrates))
277 WARN_ON(1); 277 return -EINVAL;
278
279 /*
280 * Since we use a u32 for rate bitmaps in
281 * ieee80211_get_response_rate, we cannot
282 * have more than 32 legacy rates.
283 */
284 if (WARN_ON(sband->n_bitrates > 32))
278 return -EINVAL; 285 return -EINVAL;
279 }
280 286
281 for (i = 0; i < sband->n_channels; i++) { 287 for (i = 0; i < sband->n_channels; i++) {
282 sband->channels[i].orig_flags = 288 sband->channels[i].orig_flags =
diff --git a/net/wireless/util.c b/net/wireless/util.c
index e76cc28b0345..487cdd9bcffc 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -9,7 +9,7 @@
9 9
10struct ieee80211_rate * 10struct ieee80211_rate *
11ieee80211_get_response_rate(struct ieee80211_supported_band *sband, 11ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
12 u64 basic_rates, int bitrate) 12 u32 basic_rates, int bitrate)
13{ 13{
14 struct ieee80211_rate *result = &sband->bitrates[0]; 14 struct ieee80211_rate *result = &sband->bitrates[0];
15 int i; 15 int i;