Skip to content

Commit

Permalink
Bluetooth: L2CAP: Ignore packets received while disconnecting
Browse files Browse the repository at this point in the history
Drop packets received while disconnecting since they would most likely
be flushed once peer respond there is no gain in keeping them on a
queue.

Signed-off-by: Luiz Augusto von Dentz <[email protected]>
  • Loading branch information
Vudentz authored and jhedberg committed Dec 13, 2019
1 parent 5d26693 commit 99066db
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions subsys/bluetooth/host/l2cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,19 @@ static void l2cap_chan_le_recv(struct bt_l2cap_le_chan *chan,

l2cap_chan_send_credits(chan, buf, 1);
}

static void l2cap_chan_recv_queue(struct bt_l2cap_le_chan *chan,
struct net_buf *buf)
{
if (chan->chan.state == BT_L2CAP_DISCONNECT) {
BT_WARN("Ignoring data received while disconnecting");
net_buf_unref(buf);
return;
}

net_buf_put(&chan->rx_queue, buf);
k_work_submit(&chan->rx_work);
}
#endif /* CONFIG_BT_L2CAP_DYNAMIC_CHANNEL */

static void l2cap_chan_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
Expand All @@ -1701,8 +1714,7 @@ static void l2cap_chan_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
struct bt_l2cap_le_chan *ch = BT_L2CAP_LE_CHAN(chan);

if (L2CAP_LE_CID_IS_DYN(ch->rx.cid)) {
net_buf_put(&ch->rx_queue, net_buf_ref(buf));
k_work_submit(&ch->rx_work);
l2cap_chan_recv_queue(ch, buf);
return;
}
#endif /* CONFIG_BT_L2CAP_DYNAMIC_CHANNEL */
Expand Down

0 comments on commit 99066db

Please sign in to comment.