瀏覽代碼

mac80211_hwsim: Check idle state on TX

Track the idle state for hwsim radios and reject TX if mac80211 is
trying to transmit something when the radio is supposed to be idle. In
addition, do not deliver frames if the receiving radio is in the idle
state.

Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Jouni Malinen 15 年之前
父節點
當前提交
70541839dd
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11 2
      drivers/net/wireless/mac80211_hwsim.c

+ 11 - 2
drivers/net/wireless/mac80211_hwsim.c

@@ -284,7 +284,7 @@ struct mac80211_hwsim_data {
 	struct ieee80211_channel *channel;
 	struct ieee80211_channel *channel;
 	unsigned long beacon_int; /* in jiffies unit */
 	unsigned long beacon_int; /* in jiffies unit */
 	unsigned int rx_filter;
 	unsigned int rx_filter;
-	int started;
+	bool started, idle;
 	struct timer_list beacon_timer;
 	struct timer_list beacon_timer;
 	enum ps_mode {
 	enum ps_mode {
 		PS_DISABLED, PS_ENABLED, PS_AUTO_POLL, PS_MANUAL_POLL
 		PS_DISABLED, PS_ENABLED, PS_AUTO_POLL, PS_MANUAL_POLL
@@ -402,6 +402,12 @@ static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 	struct ieee80211_rx_status rx_status;
 	struct ieee80211_rx_status rx_status;
 
 
+	if (data->idle) {
+		printk(KERN_DEBUG "%s: Trying to TX when idle - reject\n",
+		       wiphy_name(hw->wiphy));
+		return false;
+	}
+
 	memset(&rx_status, 0, sizeof(rx_status));
 	memset(&rx_status, 0, sizeof(rx_status));
 	/* TODO: set mactime */
 	/* TODO: set mactime */
 	rx_status.freq = data->channel->center_freq;
 	rx_status.freq = data->channel->center_freq;
@@ -428,7 +434,8 @@ static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
 		if (data == data2)
 		if (data == data2)
 			continue;
 			continue;
 
 
-		if (!data2->started || !hwsim_ps_rx_ok(data2, skb) ||
+		if (data2->idle || !data2->started ||
+		    !hwsim_ps_rx_ok(data2, skb) ||
 		    !data->channel || !data2->channel ||
 		    !data->channel || !data2->channel ||
 		    data->channel->center_freq != data2->channel->center_freq ||
 		    data->channel->center_freq != data2->channel->center_freq ||
 		    !(data->group & data2->group))
 		    !(data->group & data2->group))
@@ -571,6 +578,8 @@ static int mac80211_hwsim_config(struct ieee80211_hw *hw, u32 changed)
 	       !!(conf->flags & IEEE80211_CONF_IDLE),
 	       !!(conf->flags & IEEE80211_CONF_IDLE),
 	       !!(conf->flags & IEEE80211_CONF_PS));
 	       !!(conf->flags & IEEE80211_CONF_PS));
 
 
+	data->idle = !!(conf->flags & IEEE80211_CONF_IDLE);
+
 	data->channel = conf->channel;
 	data->channel = conf->channel;
 	if (!data->started || !data->beacon_int)
 	if (!data->started || !data->beacon_int)
 		del_timer(&data->beacon_timer);
 		del_timer(&data->beacon_timer);