shared/att: Confirm indications without a registered handler
PATCH v3 1/2 shared/att: Confirm indications without a registered handler
When no GATT client is attached to the bearer nothing registers for Handle Value Indication, so handle_notify() answers it with an Error Response. That is not a valid reply to an indication (Core Vol 3, Part F, 3.4.7.2 allows only a Handle Value Confirmation): the peer keeps waiting for the confirmation and drops the link when its 30 second ATT transaction timeout expires.
This happens on incoming connections when ReverseServiceDiscovery or [GATT] Client is disabled in main.conf. iOS sends Service Changed as the first PDU on every bonded reconnect:
Quoted 1 line
ACL Data RX: Handle 64 flags
0x02dlen 11
ATT: Handle Value Indication (0x1d) len 6
Handle: 0x0008
Data: 0a00ffff
< ACL Data TX: Handle 64 flags 0x00 dlen 9
ATT: Error Response (0x01) len 4
Handle Value Indication (0x1d)
Handle: 0x0000
Error: Request Not Supported (0x06)...
Quoted 1 line
HCI Event: Disconnect Complete (
0x05) plen 4 #113 34.912832
Status: Success (0x00)
Handle: 64
Reason: Remote User Terminated Connection (0x13)bt_att never confirms an indication itself: the GATT client's indication handler does. When no handler is registered, send the confirmation from bt_att on the channel the indication arrived on. With a GATT client attached nothing changes, its handler still sends the confirmation.
--- src/shared/att.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
src/shared/att.c +13 -6
@@ -1086,12 +1086,19 @@ static void handle_notify(struct bt_att_chan *chan, uint8_t *pdu, } not_supported: -/* -* If this was not a command and no handler was registered for it, -* respond with "Not Supported" -*/ -if (!found &&get_op_type (opcode) !=ATT_OP_TYPE_CMD ) -respond_not_supported (att, opcode); +if (!found) { +/* +* An indication can only be answered with a confirmation, an +* Error Response leaves the peer waiting until its ATT +* transaction times out. If this was not a command and no +* handler was registered for it, respond with "Not Supported". +*/ +if (opcode ==BT_ATT_OP_HANDLE_IND ) +bt_att_chan_send (chan,BT_ATT_OP_HANDLE_CONF ,NULL ,0 , +NULL ,NULL ,NULL ); +else if (get_op_type (opcode) !=ATT_OP_TYPE_CMD ) +respond_not_supported (att, opcode); + }bt_att_unref (att); }
base-commit: 1adfe662efeff12997df9ddd0960dbd0de9c8ea7
Signature · 1 line
2.43.0
PATCH v3 2/2 unit/test-gatt: Add test for indication without a handler
A server with no GATT client on the bearer has nothing registered for Handle Value Indication. Check that it answers one with a Handle Value Confirmation instead of an Error Response.
--- unit/test-gatt.c | 6 ++++++ 1 file changed, 6 insertions(+)
unit/test-gatt.c +6 -0
@@ -5205,6 +5205,12 @@ int main(int argc, char *argv[])raw_pdu (0xff ,0x00 ), raw_pdu()); +define_test_server ("/robustness/indication-no-handler" , + test_server, service_db_1,NULL , +raw_pdu (0x03 ,0x00 ,0x02 ), +raw_pdu (0x1d ,0x08 ,0x00 ,0x01 ,0x00 ,0xff ,0xff ), +raw_pdu (0x1e )); + define_test_client("/robustness/client-mtu-rsp-short", test_client, NULL, &test_client_init_fail, raw_pdu(0x02, 0x00, 0x02),
Signature · 1 line
2.43.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1219879/
---Test result---
Test Summary:
CheckPatch PASS 0.95 seconds GitLint PASS 0.65 seconds BuildEll PASS 20.69 seconds BluezMake PASS 311.67 seconds MakeCheck PASS 14.47 seconds MakeDistcheck PASS 147.63 seconds CheckValgrind PASS 356.31 seconds CheckSmatch PASS 318.13 seconds bluezmakeextell PASS 100.95 seconds TestFunctional PASS 1227.69 seconds IncrementalBuild PASS 348.55 seconds ScanBuild PASS 1205.34 seconds
https://github.com/bluez/bluez/pull/2888
---
Regards,
Linux Bluetooth