Skip to content

Commit d96f129

Browse files
committed
Revert "[nrf noup] bluetooth: conn: Skip buffer ref count check in send_buf"
This reverts commit adb8f4e. Signed-off-by: Marek Pieta <[email protected]>
1 parent 69ad052 commit d96f129

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -711,27 +711,19 @@ static int send_buf(struct bt_conn *conn, struct net_buf *buf,
711711

712712
uint16_t frag_len = MIN(conn_mtu(conn), len);
713713

714-
/* If ATT sent callback is delayed until data transmission
715-
* is done by BLE controller, the transmitted buffer may
716-
* have an additional reference. The reference is used to
717-
* extend lifetime of the net buffer until the data
718-
* transmission is confirmed by ACK of the remote.
714+
/* Check that buf->ref is 1 or 2. It would be 1 if this was
715+
* the only reference (e.g. buf was removed from the conn
716+
* tx_queue). It would be 2 if the tx_data_pull kept it on
717+
* the tx_queue for segmentation.
719718
*
720-
* send_buf function can be called multiple times, if buffer
721-
* has to be fragmented over HCI. In that case, the callback
722-
* is provided as an argument only for the last transmitted
723-
* fragment. The `buf->ref == 1` (or 2) check is skipped
724-
* because it's impossible to properly validate number of
725-
* references for the sent fragments if buffers may have the
726-
* additional reference.
727-
*
728-
* Otherwise, check that buf->ref is 1 or 2. It would be 1
729-
* if this was the only reference (e.g. buf was removed from
730-
* the conn tx_queue). It would be 2 if the tx_data_pull
731-
* kept it on the tx_queue for segmentation.
719+
* Allow for an additional buffer reference if callback is
720+
* provided. This can be used to extend lifetime of the net
721+
* buffer until the data transmission is confirmed by ACK of
722+
* the remote.
732723
*/
733-
__ASSERT_NO_MSG(IS_ENABLED(CONFIG_BT_ATT_SENT_CB_AFTER_TX) || (buf->ref == 1) ||
734-
(buf->ref == 2));
724+
if (buf->ref > 2 + (cb ? 1 : 0)) {
725+
__ASSERT_NO_MSG(false);
726+
}
735727

736728
/* The reference is always transferred to the frag, so when
737729
* the frag is destroyed, the parent reference is decremented.

0 commit comments

Comments
 (0)