All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mac80211_hwsim: check ATTR_FREQ for wmediumd (netlink) packets
@ 2015-12-01 22:13 arwelle
  2015-12-02  9:57 ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: arwelle @ 2015-12-01 22:13 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless

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.
The frequency is also checked against data2->tmp_chan if non-zero to support
the off-channel/scan case.

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

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 194264c..94c30cb 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2876,10 +2876,19 @@ 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 (data2->tmp_chan) {
+			if (rx_status.freq != data2->tmp_chan->center_freq)
+				goto out;
+		}
+		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]);
-- 
2.1.4


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

* Re: [PATCH v2] mac80211_hwsim: check ATTR_FREQ for wmediumd (netlink) packets
  2015-12-01 22:13 [PATCH v2] mac80211_hwsim: check ATTR_FREQ for wmediumd (netlink) packets arwelle
@ 2015-12-02  9:57 ` Johannes Berg
  2015-12-02 19:30   ` Adam R. Welle
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2015-12-02  9:57 UTC (permalink / raw)
  To: arwelle; +Cc: linux-wireless

On Tue, 2015-12-01 at 17:13 -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.
> The frequency is also checked against data2->tmp_chan if non-zero to
> support
> the off-channel/scan case.
> 
Applied. I added locking and made a change to accept both the off-
channel and non-offchannel since the internal datapath also does that
and we don't stop other operation for off-channel.

johannes

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

* RE: [PATCH v2] mac80211_hwsim: check ATTR_FREQ for wmediumd (netlink) packets
  2015-12-02  9:57 ` Johannes Berg
@ 2015-12-02 19:30   ` Adam R. Welle
  2015-12-03  9:10     ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Adam R. Welle @ 2015-12-02 19:30 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

PiBBcHBsaWVkLiBJIGFkZGVkIGxvY2tpbmcgYW5kIG1hZGUgYSBjaGFuZ2UgdG8gYWNjZXB0IGJv
dGggdGhlIG9mZi0NCj4gY2hhbm5lbCBhbmQgbm9uLW9mZmNoYW5uZWwgc2luY2UgdGhlIGludGVy
bmFsIGRhdGFwYXRoIGFsc28gZG9lcyB0aGF0DQo+IGFuZCB3ZSBkb24ndCBzdG9wIG90aGVyIG9w
ZXJhdGlvbiBmb3Igb2ZmLWNoYW5uZWwuDQoNCkRvZXMgeW91ciBjaGFuZ2Ugb25seSB0aHJvdyBh
d2F5IHBhY2tldHMgd2hlbiB0bXBfY2hhbiBpcyBzZXQ/IEkgd2FzIHVuZGVyDQp0aGUgaW1wcmVz
c2lvbiB0aGF0IG1vc3Qgb2YgdGhlIHRpbWUgdG1wX2NoYW4gd291bGQgYmUgbnVsbC4NCg0KQWRh
bQ0K

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

* Re: [PATCH v2] mac80211_hwsim: check ATTR_FREQ for wmediumd (netlink) packets
  2015-12-02 19:30   ` Adam R. Welle
@ 2015-12-03  9:10     ` Johannes Berg
  2015-12-03 14:18       ` Adam R. Welle
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2015-12-03  9:10 UTC (permalink / raw)
  To: Adam R. Welle; +Cc: linux-wireless

On Wed, 2015-12-02 at 19:30 +0000, Adam R. Welle wrote:
> > Applied. I added locking and made a change to accept both the off-
> > channel and non-offchannel since the internal datapath also does
> > that
> > and we don't stop other operation for off-channel.
> 
> Does your change only throw away packets when tmp_chan is set? I was
> under the impression that most of the time tmp_chan would be null.
> 
Yeah, umm, that expression was wrong. Thanks.

It should be

                if (rx_status.freq != data2->channel->center_freq &&
                    (!data2->tmp_chan ||
                     rx_status.freq != data2->tmp_chan->center_freq)) {

I'll fix it.

johannes

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

* RE: [PATCH v2] mac80211_hwsim: check ATTR_FREQ for wmediumd (netlink) packets
  2015-12-03  9:10     ` Johannes Berg
@ 2015-12-03 14:18       ` Adam R. Welle
  0 siblings, 0 replies; 5+ messages in thread
From: Adam R. Welle @ 2015-12-03 14:18 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

PiDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCBpZiAocnhfc3RhdHVzLmZyZXEgIT0gZGF0YTItPmNo
YW5uZWwtPmNlbnRlcl9mcmVxICYmDQo+IMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKg
wqDCoMKgwqAoIWRhdGEyLT50bXBfY2hhbiB8fA0KPiDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDC
oMKgwqDCoMKgwqDCoMKgwqByeF9zdGF0dXMuZnJlcSAhPSBkYXRhMi0+dG1wX2NoYW4tPmNlbnRl
cl9mcmVxKSkgew0KDQpQZXJmZWN0LCB0aGFuayB5b3UhDQoNCkFkYW0NCg0K

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

end of thread, other threads:[~2015-12-03 14:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-01 22:13 [PATCH v2] mac80211_hwsim: check ATTR_FREQ for wmediumd (netlink) packets arwelle
2015-12-02  9:57 ` Johannes Berg
2015-12-02 19:30   ` Adam R. Welle
2015-12-03  9:10     ` Johannes Berg
2015-12-03 14:18       ` Adam R. Welle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.