Skip to content

Commit 641cf2a

Browse files
sei-awellejmberg-intel
authored andcommitted
mac80211_hwsim: check ATTR_FREQ for wmediumd (netlink) packets
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 to support the "hw" off-channel/scan case. Signed-off-by: Adam Welle <[email protected]> [allow both simultaneously, add locking] Signed-off-by: Johannes Berg <[email protected]>
1 parent 89f44d8 commit 641cf2a

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

drivers/net/wireless/mac80211_hwsim.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,10 +2879,25 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,
28792879

28802880
/* A frame is received from user space */
28812881
memset(&rx_status, 0, sizeof(rx_status));
2882-
/* TODO: Check ATTR_FREQ if it exists, and maybe throw away off-channel
2883-
* packets?
2884-
*/
2885-
rx_status.freq = data2->channel->center_freq;
2882+
if (info->attrs[HWSIM_ATTR_FREQ]) {
2883+
/* throw away off-channel packets, but allow both the temporary
2884+
* ("hw" scan/remain-on-channel) and regular channel, since the
2885+
* internal datapath also allows this
2886+
*/
2887+
mutex_lock(&data2->mutex);
2888+
rx_status.freq = nla_get_u32(info->attrs[HWSIM_ATTR_FREQ]);
2889+
2890+
if (rx_status.freq != data2->channel->center_freq &&
2891+
(!data2->tmp_chan ||
2892+
rx_status.freq != data2->tmp_chan->center_freq)) {
2893+
mutex_unlock(&data2->mutex);
2894+
goto out;
2895+
}
2896+
mutex_unlock(&data2->mutex);
2897+
} else {
2898+
rx_status.freq = data2->channel->center_freq;
2899+
}
2900+
28862901
rx_status.band = data2->channel->band;
28872902
rx_status.rate_idx = nla_get_u32(info->attrs[HWSIM_ATTR_RX_RATE]);
28882903
rx_status.signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]);

0 commit comments

Comments
 (0)