diff mbox

mac80211_hwsim: check ATTR_FREQ for wmediumd (netlink) packets

Message ID 1446477900-10430-1-git-send-email-arwelle@cert.org (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show

Commit Message

arwelle@cert.org Nov. 2, 2015, 3:25 p.m. UTC
From: Adam Welle <arwelle@cert.org>

If a packet is received from netlink with the frequency value set it is
checked against the current radio's frequency and discarded if different.

Signed-off-by: Adam Welle <arwelle@cert.org>
---
 drivers/net/wireless/mac80211_hwsim.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Johannes Berg Nov. 26, 2015, 4:48 p.m. UTC | #1
On Mon, 2015-11-02 at 10:25 -0500, arwelle@cert.org wrote:
> From: Adam Welle <arwelle@cert.org>
> 
> If a packet is received from netlink with the frequency value set it
> is
> checked against the current radio's frequency and discarded if
> different.
> 
Reviewing this more closely, it seems that the frequency should also be
checked against data->tmp_channel if that's non-zero, to support the
"hw" off-channel/scan case.

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index ee46f46..191b576 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2827,10 +2827,16 @@  static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,
 
 	/* A frame is received from user space */
 	memset(&rx_status, 0, sizeof(rx_status));
-	/* TODO: Check ATTR_FREQ if it exists, and maybe throw away off-channel
-	 * packets?
-	 */
-	rx_status.freq = data2->channel->center_freq;
+
+	/* Check ATTR_FREQ if it exists, and throw away off-channel packets */
+	if (info->attrs[HWSIM_ATTR_FREQ]) {
+		rx_status.freq = nla_get_u32(info->attrs[HWSIM_ATTR_FREQ]);
+		if (rx_status.freq != data2->channel->center_freq)
+			goto out;
+	} else {
+		rx_status.freq = data2->channel->center_freq;
+	}
+
 	rx_status.band = data2->channel->band;
 	rx_status.rate_idx = nla_get_u32(info->attrs[HWSIM_ATTR_RX_RATE]);
 	rx_status.signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]);