linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] mac80211_hwsim: Implements a check for ATTR_FREQ inside hwsim_cloned_frame_received_nl
@ 2015-10-30 21:00 arwelle
  2015-11-02 12:27 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: arwelle @ 2015-10-30 21:00 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless

From: Adam Welle <arwelle@cert.org>

If a frame is received from netlink with this 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 | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index ee46f46..78faa72 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2827,10 +2827,17 @@ 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]);
+	else
+		rx_status.freq = data2->channel->center_freq;
+
+	/* Drop packet if not on the same frequency as this radio */
+	if (rx_status.freq != data2->channel->center_freq)
+		goto out;
+
 	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]);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC] mac80211_hwsim: Implements a check for ATTR_FREQ inside hwsim_cloned_frame_received_nl
  2015-10-30 21:00 [RFC] mac80211_hwsim: Implements a check for ATTR_FREQ inside hwsim_cloned_frame_received_nl arwelle
@ 2015-11-02 12:27 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2015-11-02 12:27 UTC (permalink / raw)
  To: arwelle; +Cc: linux-wireless

On Fri, 2015-10-30 at 17:00 -0400, arwelle@cert.org wrote:
> From: Adam Welle <arwelle@cert.org>
> 
> If a frame is received from netlink with this value set it is checked 
> against the current radio's frequency and discarded if different.

Please line-break the commit log to <=72 characters/line.

> +	/* 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]);
> +	else
> +		rx_status.freq = data2->channel->center_freq;
> +
> +	/* Drop packet if not on the same frequency as this radio */
> +	if (rx_status.freq != data2->channel->center_freq)
> +		goto out;
> 
I think it'd make sense to have that check only in the case that the
attribute existed. I'm not too concerned about performance here, but
more generally it looks odd if you're checking when you know it can't
be different.

johannes

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-02 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-30 21:00 [RFC] mac80211_hwsim: Implements a check for ATTR_FREQ inside hwsim_cloned_frame_received_nl arwelle
2015-11-02 12:27 ` Johannes Berg

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).