From: Johannes Berg <johannes@sipsolutions.net>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 16/18] mac80211 hwsim: verify vif pointers
Date: Thu, 11 Sep 2008 00:02:01 +0200 [thread overview]
Message-ID: <20080910220426.564761000@sipsolutions.net> (raw)
In-Reply-To: 20080910220145.707263000@sipsolutions.net
mac80211-hwsim is a debugging tool for mac80211, and as such
it can very well verify that mac80211 isn't passing junk to
drivers, especially the vif pointer is prone to this because
for vlan interfaces the AP interface pointer needs to be passed.
This makes mac80211-hwsim add a magic cookie to the private vif
area and verify it whenever an operation is called that gets a
vif pointer.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
drivers/net/wireless/mac80211_hwsim.c | 58 ++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
--- everything.orig/drivers/net/wireless/mac80211_hwsim.c 2008-09-10 23:58:05.000000000 +0200
+++ everything/drivers/net/wireless/mac80211_hwsim.c 2008-09-10 23:58:11.000000000 +0200
@@ -28,6 +28,29 @@ static int radios = 2;
module_param(radios, int, 0444);
MODULE_PARM_DESC(radios, "Number of simulated radios");
+struct hwsim_vif_priv {
+ u32 magic;
+};
+
+#define HWSIM_VIF_MAGIC 0x69537748
+
+static inline void hwsim_check_magic(struct ieee80211_vif *vif)
+{
+ struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
+ BUG_ON(vp->magic != HWSIM_VIF_MAGIC);
+}
+
+static inline void hwsim_set_magic(struct ieee80211_vif *vif)
+{
+ struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
+ vp->magic = HWSIM_VIF_MAGIC;
+}
+
+static inline void hwsim_clear_magic(struct ieee80211_vif *vif)
+{
+ struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
+ vp->magic = 0;
+}
static struct class *hwsim_class;
@@ -210,6 +233,9 @@ static int mac80211_hwsim_tx(struct ieee
ack = mac80211_hwsim_tx_frame(hw, skb);
txi = IEEE80211_SKB_CB(skb);
+
+ hwsim_check_magic(txi->control.vif);
+
memset(&txi->status, 0, sizeof(txi->status));
if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) {
if (ack)
@@ -246,6 +272,7 @@ static int mac80211_hwsim_add_interface(
printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%s)\n",
wiphy_name(hw->wiphy), __func__, conf->type,
print_mac(mac, conf->mac_addr));
+ hwsim_set_magic(conf->vif);
return 0;
}
@@ -257,6 +284,8 @@ static void mac80211_hwsim_remove_interf
printk(KERN_DEBUG "%s:%s (type=%d mac_addr=%s)\n",
wiphy_name(hw->wiphy), __func__, conf->type,
print_mac(mac, conf->mac_addr));
+ hwsim_check_magic(conf->vif);
+ hwsim_clear_magic(conf->vif);
}
@@ -267,6 +296,8 @@ static void mac80211_hwsim_beacon_tx(voi
struct sk_buff *skb;
struct ieee80211_tx_info *info;
+ hwsim_check_magic(vif);
+
if (vif->type != NL80211_IFTYPE_AP)
return;
@@ -341,7 +372,28 @@ static void mac80211_hwsim_configure_fil
*total_flags = data->rx_filter;
}
+static int mac80211_hwsim_config_interface(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_if_conf *conf)
+{
+ hwsim_check_magic(vif);
+ return 0;
+}
+static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *info,
+ u32 changed)
+{
+ hwsim_check_magic(vif);
+}
+
+static void mac80211_hwsim_sta_notify(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ enum sta_notify_cmd cmd, const u8 *addr)
+{
+ hwsim_check_magic(vif);
+}
static const struct ieee80211_ops mac80211_hwsim_ops =
{
@@ -352,6 +404,9 @@ static const struct ieee80211_ops mac802
.remove_interface = mac80211_hwsim_remove_interface,
.config = mac80211_hwsim_config,
.configure_filter = mac80211_hwsim_configure_filter,
+ .config_interface = mac80211_hwsim_config_interface,
+ .bss_info_changed = mac80211_hwsim_bss_info_changed,
+ .sta_notify = mac80211_hwsim_sta_notify,
};
@@ -452,6 +507,9 @@ static int __init init_mac80211_hwsim(vo
BIT(NL80211_IFTYPE_AP);
hw->ampdu_queues = 1;
+ /* ask mac80211 to reserve space for magic */
+ hw->vif_data_size = sizeof(struct hwsim_vif_priv);
+
memcpy(data->channels, hwsim_channels, sizeof(hwsim_channels));
memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates));
data->band.channels = data->channels;
--
next prev parent reply other threads:[~2008-09-10 22:15 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-10 22:01 [PATCH 00/18] mac80211 cleanups and fixes Johannes Berg
2008-09-10 22:01 ` [PATCH 01/18] mac80211: move ieee80211_sta_expire Johannes Berg
2008-09-10 22:01 ` [PATCH 02/18] mac80211: move STA timer restart Johannes Berg
2008-09-10 22:01 ` [PATCH 03/18] mac80211: dont set REQ_RUN when scan finishes Johannes Berg
2008-09-10 22:01 ` [PATCH 04/18] mac80211: split off mesh handling entirely Johannes Berg
2008-09-10 22:01 ` [PATCH 05/18] mac80211: fix work race Johannes Berg
2008-09-10 22:01 ` [PATCH 06/18] mac80211: fix scan vs. interface removal race Johannes Berg
2008-09-10 22:01 ` [PATCH 07/18] mac80211: reorder MLME code more Johannes Berg
2008-09-10 22:01 ` [PATCH 08/18] mac80211: move ieee80211_set_freq to utils Johannes Berg
2008-09-10 22:01 ` [PATCH 09/18] mac80211: make bridge_packets a virtual interface option Johannes Berg
2008-09-10 22:01 ` [PATCH 10/18] mac80211: clean up scan namespace Johannes Berg
2008-09-10 22:01 ` [PATCH 11/18] mac80211: clean up some comments Johannes Berg
2008-09-10 22:01 ` [PATCH 12/18] mac80211: inform driver of basic rateset Johannes Berg
2008-09-10 22:01 ` [PATCH 13/18] mac80211: use nl80211 interface types Johannes Berg
2008-09-10 22:01 ` [PATCH 14/18] mac80211: move regular interface handling Johannes Berg
2008-09-10 22:02 ` [PATCH 15/18] mac80211: warn on some invalid vlan operations Johannes Berg
2008-09-10 22:02 ` Johannes Berg [this message]
2008-09-11 0:06 ` [PATCH 16/18] mac80211 hwsim: verify vif pointers Luis R. Rodriguez
2008-09-11 0:09 ` Johannes Berg
2008-09-11 0:17 ` Luis R. Rodriguez
2008-09-11 0:16 ` [PATCH v2 " Johannes Berg
2008-09-10 22:02 ` [PATCH 17/18] mac80211: share STA information with driver Johannes Berg
2008-09-10 22:02 ` [PATCH 18/18] mac80211 hwsim: verify sta pointers Johannes Berg
2008-09-11 0:17 ` [PATCH v2 " Johannes Berg
2008-09-11 19:26 ` Johannes Berg
2008-09-11 0:03 ` [PATCH 19/18] mac80211: small rate control changes Johannes Berg
2008-09-11 0:22 ` [PATCH 20/18] mac80211: move last_txrate_idx into RC algorithms Johannes Berg
2008-09-11 0:45 ` [PATCH 21/18] mac80211: share sta->supp_rates Johannes Berg
2008-09-11 1:04 ` [PATCH 22/18] mac80211: move txrate_idx into RC algorithms Johannes Berg
2008-09-11 1:14 ` [PATCH 23/18] mac80211: share sta_info->ht_info Johannes Berg
2008-09-11 1:17 ` [PATCH 24/18] iwlwifi: don't access mac80211's AMPDU state machine Johannes Berg
2008-09-11 3:27 ` [PATCH 25/18] mac80211: pass AP vif pointer for VLANs Johannes Berg
2008-09-11 8:29 ` [PATCH 00/18] mac80211 cleanups and fixes Sujith
2008-09-11 13:22 ` Johannes Berg
2008-09-11 16:50 ` Luis R. Rodriguez
2008-09-11 16:53 ` Johannes Berg
2008-09-11 17:10 ` Luis R. Rodriguez
2008-09-11 17:13 ` Johannes Berg
2008-09-11 17:31 ` Luis R. Rodriguez
2008-09-11 17:33 ` Luis R. Rodriguez
2008-09-11 17:39 ` Johannes Berg
2008-09-11 17:42 ` Johannes Berg
2008-09-11 17:47 ` Johannes Berg
2008-09-11 17:54 ` Luis R. Rodriguez
2008-09-12 3:14 ` Sujith
2008-09-12 7:45 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080910220426.564761000@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).