diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-09-10 20:17:01 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-09-15 16:48:23 -0400 |
commit | 81c065238644ade3869391f977438ff7ed3158db (patch) | |
tree | 501ab1359ba7dbdc65e9df6bedd78cfb15e70273 /drivers/net/wireless | |
parent | 17741cdc264e4d768167766a252210e201c1519a (diff) |
mac80211 hwsim: verify sta pointers
In analogy with the previous patch to make mac80211-hwsim
verify that the virtual interface pointers are correct,
this makes it very that it knows about all station structs.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/mac80211_hwsim.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 173dd5d2c624..da8aa83481f7 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c | |||
@@ -52,6 +52,30 @@ static inline void hwsim_clear_magic(struct ieee80211_vif *vif) | |||
52 | vp->magic = 0; | 52 | vp->magic = 0; |
53 | } | 53 | } |
54 | 54 | ||
55 | struct hwsim_sta_priv { | ||
56 | u32 magic; | ||
57 | }; | ||
58 | |||
59 | #define HWSIM_STA_MAGIC 0x6d537748 | ||
60 | |||
61 | static inline void hwsim_check_sta_magic(struct ieee80211_sta *sta) | ||
62 | { | ||
63 | struct hwsim_sta_priv *sp = (void *)sta->drv_priv; | ||
64 | WARN_ON(sp->magic != HWSIM_VIF_MAGIC); | ||
65 | } | ||
66 | |||
67 | static inline void hwsim_set_sta_magic(struct ieee80211_sta *sta) | ||
68 | { | ||
69 | struct hwsim_sta_priv *sp = (void *)sta->drv_priv; | ||
70 | sp->magic = HWSIM_VIF_MAGIC; | ||
71 | } | ||
72 | |||
73 | static inline void hwsim_clear_sta_magic(struct ieee80211_sta *sta) | ||
74 | { | ||
75 | struct hwsim_sta_priv *sp = (void *)sta->drv_priv; | ||
76 | sp->magic = 0; | ||
77 | } | ||
78 | |||
55 | static struct class *hwsim_class; | 79 | static struct class *hwsim_class; |
56 | 80 | ||
57 | static struct ieee80211_hw **hwsim_radios; | 81 | static struct ieee80211_hw **hwsim_radios; |
@@ -235,6 +259,8 @@ static int mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
235 | txi = IEEE80211_SKB_CB(skb); | 259 | txi = IEEE80211_SKB_CB(skb); |
236 | 260 | ||
237 | hwsim_check_magic(txi->control.vif); | 261 | hwsim_check_magic(txi->control.vif); |
262 | if (txi->control.sta) | ||
263 | hwsim_check_sta_magic(txi->control.sta); | ||
238 | 264 | ||
239 | memset(&txi->status, 0, sizeof(txi->status)); | 265 | memset(&txi->status, 0, sizeof(txi->status)); |
240 | if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) { | 266 | if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) { |
@@ -394,6 +420,22 @@ static void mac80211_hwsim_sta_notify(struct ieee80211_hw *hw, | |||
394 | struct ieee80211_sta *sta) | 420 | struct ieee80211_sta *sta) |
395 | { | 421 | { |
396 | hwsim_check_magic(vif); | 422 | hwsim_check_magic(vif); |
423 | switch (cmd) { | ||
424 | case STA_NOTIFY_ADD: | ||
425 | hwsim_set_sta_magic(sta); | ||
426 | break; | ||
427 | case STA_NOTIFY_REMOVE: | ||
428 | hwsim_clear_sta_magic(sta); | ||
429 | break; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | static int mac80211_hwsim_set_tim(struct ieee80211_hw *hw, | ||
434 | struct ieee80211_sta *sta, | ||
435 | bool set) | ||
436 | { | ||
437 | hwsim_check_sta_magic(sta); | ||
438 | return 0; | ||
397 | } | 439 | } |
398 | 440 | ||
399 | static const struct ieee80211_ops mac80211_hwsim_ops = | 441 | static const struct ieee80211_ops mac80211_hwsim_ops = |
@@ -408,6 +450,7 @@ static const struct ieee80211_ops mac80211_hwsim_ops = | |||
408 | .config_interface = mac80211_hwsim_config_interface, | 450 | .config_interface = mac80211_hwsim_config_interface, |
409 | .bss_info_changed = mac80211_hwsim_bss_info_changed, | 451 | .bss_info_changed = mac80211_hwsim_bss_info_changed, |
410 | .sta_notify = mac80211_hwsim_sta_notify, | 452 | .sta_notify = mac80211_hwsim_sta_notify, |
453 | .set_tim = mac80211_hwsim_set_tim, | ||
411 | }; | 454 | }; |
412 | 455 | ||
413 | 456 | ||
@@ -510,6 +553,7 @@ static int __init init_mac80211_hwsim(void) | |||
510 | 553 | ||
511 | /* ask mac80211 to reserve space for magic */ | 554 | /* ask mac80211 to reserve space for magic */ |
512 | hw->vif_data_size = sizeof(struct hwsim_vif_priv); | 555 | hw->vif_data_size = sizeof(struct hwsim_vif_priv); |
556 | hw->sta_data_size = sizeof(struct hwsim_sta_priv); | ||
513 | 557 | ||
514 | memcpy(data->channels, hwsim_channels, sizeof(hwsim_channels)); | 558 | memcpy(data->channels, hwsim_channels, sizeof(hwsim_channels)); |
515 | memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); | 559 | memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); |