Skip to content

Commit

Permalink
mac802154: don't deliver packets to devices that are down
Browse files Browse the repository at this point in the history
Only one WPAN devices can be active at any given time, so only deliver
packets to that one interface that is actually up. Multiple monitors may
be up at any given time, but we don't have to deliver to monitors that
are down either.

Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Phoebe Buckheister authored and davem330 committed Jun 11, 2014
1 parent a374eeb commit 2d3b5b0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion net/mac802154/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb)

rcu_read_lock();
list_for_each_entry_rcu(sdata, &priv->slaves, list) {
if (sdata->type != IEEE802154_DEV_MONITOR)
if (sdata->type != IEEE802154_DEV_MONITOR ||
!netif_running(sdata->dev))
continue;

skb2 = skb_clone(skb, GFP_ATOMIC);
Expand Down
11 changes: 7 additions & 4 deletions net/mac802154/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,23 @@ mac802154_subif_rx(struct ieee802154_dev *hw, struct sk_buff *skb, u8 lqi)

if (skb->len < 2) {
pr_debug("got invalid frame\n");
goto out;
goto fail;
}
crc = crc_ccitt(0, skb->data, skb->len);
if (crc) {
pr_debug("CRC mismatch\n");
goto out;
goto fail;
}
skb_trim(skb, skb->len - 2); /* CRC */
}

mac802154_monitors_rx(priv, skb);
mac802154_wpans_rx(priv, skb);
out:
dev_kfree_skb(skb);

return;

fail:
kfree_skb(skb);
}

static void mac802154_rx_worker(struct work_struct *work)
Expand Down
13 changes: 8 additions & 5 deletions net/mac802154/wpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,6 @@ static int mac802154_parse_frame_start(struct sk_buff *skb,
void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb)
{
int ret;
struct sk_buff *sskb;
struct mac802154_sub_if_data *sdata;
struct ieee802154_hdr hdr;

Expand All @@ -579,12 +578,16 @@ void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb)

rcu_read_lock();
list_for_each_entry_rcu(sdata, &priv->slaves, list) {
if (sdata->type != IEEE802154_DEV_WPAN)
if (sdata->type != IEEE802154_DEV_WPAN ||
!netif_running(sdata->dev))
continue;

sskb = skb_clone(skb, GFP_ATOMIC);
if (sskb)
mac802154_subif_frame(sdata, sskb, &hdr);
mac802154_subif_frame(sdata, skb, &hdr);
skb = NULL;
break;
}
rcu_read_unlock();

if (skb)
kfree_skb(skb);
}

0 comments on commit 2d3b5b0

Please sign in to comment.