mac802154: Ensure proper scan-level filtering

We now have a fine grained filtering information so let's ensure proper
filtering in scan mode, which means that only beacons are processed.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Alexander Aring <aahringo@redhat.com>
Link: https://lore.kernel.org/r/20221019134423.877169-4-miquel.raynal@bootlin.com
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
This commit is contained in:
Miquel Raynal 2022-10-19 15:44:23 +02:00 committed by Stefan Schmidt
parent 19177eedcf
commit 4161634bce

View File

@ -34,6 +34,7 @@ ieee802154_subif_frame(struct ieee802154_sub_if_data *sdata,
struct sk_buff *skb, const struct ieee802154_hdr *hdr)
{
struct wpan_dev *wpan_dev = &sdata->wpan_dev;
struct wpan_phy *wpan_phy = sdata->local->hw.phy;
__le16 span, sshort;
int rc;
@ -42,6 +43,17 @@ ieee802154_subif_frame(struct ieee802154_sub_if_data *sdata,
span = wpan_dev->pan_id;
sshort = wpan_dev->short_addr;
/* Level 3 filtering: Only beacons are accepted during scans */
if (sdata->required_filtering == IEEE802154_FILTERING_3_SCAN &&
sdata->required_filtering > wpan_phy->filtering) {
if (mac_cb(skb)->type != IEEE802154_FC_TYPE_BEACON) {
dev_dbg(&sdata->dev->dev,
"drop non-beacon frame (0x%x) during scan\n",
mac_cb(skb)->type);
goto fail;
}
}
switch (mac_cb(skb)->dest.mode) {
case IEEE802154_ADDR_NONE:
if (mac_cb(skb)->dest.mode != IEEE802154_ADDR_NONE)
@ -277,10 +289,6 @@ void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb)
ieee802154_monitors_rx(local, skb);
/* TODO: Handle upcomming receive path where the PHY is at the
* IEEE802154_FILTERING_NONE level during a scan.
*/
/* Level 1 filtering: Check the FCS by software when relevant */
if (local->hw.phy->filtering == IEEE802154_FILTERING_NONE) {
crc = crc_ccitt(0, skb->data, skb->len);