Skip to content

Commit 5d26693

Browse files
Vudentzjhedberg
authored andcommitted
Bluetooth: L2CAP: Add dedicated pool for disconnect request
This prevents disconnect request packets to not being sent due to lack of buffers normally caused by flooding or congestion. Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent aa9a1f6 commit 5d26693

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

subsys/bluetooth/host/l2cap.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
#define L2CAP_CONN_TIMEOUT K_SECONDS(40)
5151
#define L2CAP_DISC_TIMEOUT K_SECONDS(2)
5252

53+
/* Dedicated pool for disconnect buffers so they are guaranteed to be send
54+
* even in case of data congestion due to flooding.
55+
*/
56+
NET_BUF_POOL_FIXED_DEFINE(disc_pool, 1,
57+
BT_L2CAP_BUF_SIZE(CONFIG_BT_L2CAP_TX_MTU), NULL);
58+
5359
#if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL)
5460
/* Size of MTU is based on the maximum amount of data the buffer can hold
5561
* excluding ACL and driver headers.
@@ -376,9 +382,14 @@ static struct net_buf *l2cap_create_le_sig_pdu(struct net_buf *buf,
376382
u16_t len)
377383
{
378384
struct bt_l2cap_sig_hdr *hdr;
385+
struct net_buf_pool *pool = NULL;
386+
387+
if (code == BT_L2CAP_DISCONN_REQ) {
388+
pool = &disc_pool;
389+
}
379390

380391
/* Don't wait more than the minimum RTX timeout of 2 seconds */
381-
buf = bt_l2cap_create_pdu_timeout(NULL, 0, K_SECONDS(2));
392+
buf = bt_l2cap_create_pdu_timeout(pool, 0, K_SECONDS(2));
382393
if (!buf) {
383394
/* If it was not possible to allocate a buffer within the
384395
* timeout return NULL.

0 commit comments

Comments
 (0)