Skip to content

Commit c3c7b54

Browse files
hermabecarlescufi
authored andcommitted
Bluetooth: Host: Option for disabling of ATT auto retry
The automatic elevation of security and retry of ATT requests interferes with some tests that expect authentication failures. Affecting GATT/CL/GAR/BI-42-C Signed-off-by: Herman Berget <[email protected]>
1 parent 12e57d4 commit c3c7b54

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

subsys/bluetooth/host/Kconfig.gatt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ config BT_ATT_PREPARE_COUNT
2424
Number of buffers available for ATT prepare write, setting
2525
this to 0 disables GATT long/reliable writes.
2626

27+
config BT_ATT_RETRY_ON_SEC_ERR
28+
bool "Automatic security elevation and retry on security errors"
29+
default y
30+
depends on BT_SMP
31+
help
32+
If an ATT request fails due to insufficient security, the host will
33+
try to elevate the security level and retry the ATT request.
34+
2735
config BT_EATT
2836
bool "Enhanced ATT Bearers support [EXPERIMENTAL]"
2937
depends on BT_L2CAP_ECRED

subsys/bluetooth/host/att.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,7 +2241,7 @@ static uint8_t att_signed_write_cmd(struct bt_att_chan *chan, struct net_buf *bu
22412241
#endif /* CONFIG_BT_SIGNING */
22422242

22432243
#if defined(CONFIG_BT_GATT_CLIENT)
2244-
#if defined(CONFIG_BT_SMP)
2244+
#if defined(CONFIG_BT_ATT_RETRY_ON_SEC_ERR)
22452245
static int att_change_security(struct bt_conn *conn, uint8_t err)
22462246
{
22472247
bt_security_t sec;
@@ -2301,7 +2301,7 @@ static int att_change_security(struct bt_conn *conn, uint8_t err)
23012301

23022302
return bt_conn_set_security(conn, sec);
23032303
}
2304-
#endif /* CONFIG_BT_SMP */
2304+
#endif /* CONFIG_BT_ATT_RETRY_ON_SEC_ERR */
23052305

23062306
static uint8_t att_error_rsp(struct bt_att_chan *chan, struct net_buf *buf)
23072307
{
@@ -2320,13 +2320,13 @@ static uint8_t att_error_rsp(struct bt_att_chan *chan, struct net_buf *buf)
23202320
}
23212321

23222322
err = rsp->error;
2323-
#if defined(CONFIG_BT_SMP)
2323+
#if defined(CONFIG_BT_ATT_RETRY_ON_SEC_ERR)
23242324
/* Check if error can be handled by elevating security. */
23252325
if (!att_change_security(chan->chan.chan.conn, err)) {
23262326
chan->req->retrying = true;
23272327
return 0;
23282328
}
2329-
#endif /* CONFIG_BT_SMP */
2329+
#endif /* CONFIG_BT_ATT_RETRY_ON_SEC_ERR */
23302330

23312331
done:
23322332
return att_handle_rsp(chan, NULL, 0, err);

0 commit comments

Comments
 (0)