Skip to content

Commit

Permalink
bluetooth: att: Properly retry on errors mid-encryption.
Browse files Browse the repository at this point in the history
We may bet an ATT error back while an upgrade to the security
is already in progress, in which case we should still retry the
ATT request when the retry config is enabled.

Signed-off-by: Peter Johanson <[email protected]>
  • Loading branch information
petejohanson committed Jan 26, 2024
1 parent ccb7cd9 commit 339570e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion subsys/bluetooth/host/att.c
Original file line number Diff line number Diff line change
Expand Up @@ -2489,6 +2489,9 @@ static uint8_t att_error_rsp(struct bt_att_chan *chan, struct net_buf *buf)
{
struct bt_att_error_rsp *rsp;
uint8_t err;
#if defined(CONFIG_BT_ATT_RETRY_ON_SEC_ERR)
uint8_t set_sec_err;
#endif

rsp = (void *)buf->data;

Expand All @@ -2514,7 +2517,8 @@ static uint8_t att_error_rsp(struct bt_att_chan *chan, struct net_buf *buf)
err = rsp->error;
#if defined(CONFIG_BT_ATT_RETRY_ON_SEC_ERR)
/* Check if error can be handled by elevating security. */
if (!att_change_security(chan->chan.chan.conn, err)) {
set_sec_err = att_change_security(chan->chan.chan.conn, err);
if (set_sec_err >= 0 || set_sec_err == -EBUSY) {
/* ATT timeout work is normally cancelled in att_handle_rsp.
* However retrying is special case, so the timeout shall
* be cancelled here.
Expand Down

0 comments on commit 339570e

Please sign in to comment.