2014-09-24 10:14:46

by Johan Hedberg

[permalink] [raw]
Subject: [PATCH] Bluetooth: Fix reason code used for rejecting SCO connections

From: Johan Hedberg <[email protected]>

The core specification defines valid values for the
HCI_Reject_Synchronous_Connection_Request command to be 0x0D-0x0F. So
far the code has been using HCI_ERROR_REMOTE_USER_TERM (0x13) which is
not a valid value and is therefore being rejected by some controllers:

> HCI Event: Connect Request (0x04) plen 10
bdaddr 40:6F:2A:6A:E5:E0 class 0x000000 type eSCO
< HCI Command: Reject Synchronous Connection (0x01|0x002a) plen 7
bdaddr 40:6F:2A:6A:E5:E0 reason 0x13
Reason: Remote User Terminated Connection
> HCI Event: Command Status (0x0f) plen 4
Reject Synchronous Connection (0x01|0x002a) status 0x12 ncmd 1
Error: Invalid HCI Command Parameters

This patch introduces a new define for a value from the valid range
(0x0d == Connection Rejected Due To Limited Resources) and uses it
instead for rejecting incoming connections.

Signed-off-by: Johan Hedberg <[email protected]>
---
include/net/bluetooth/hci.h | 1 +
net/bluetooth/hci_conn.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 3f8547f1c6f8..6e8f24967308 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -385,6 +385,7 @@ enum {
#define HCI_ERROR_AUTH_FAILURE 0x05
#define HCI_ERROR_MEMORY_EXCEEDED 0x07
#define HCI_ERROR_CONNECTION_TIMEOUT 0x08
+#define HCI_ERROR_REJ_LIMITED_RESOURCES 0x0d
#define HCI_ERROR_REJ_BAD_ADDR 0x0f
#define HCI_ERROR_REMOTE_USER_TERM 0x13
#define HCI_ERROR_REMOTE_LOW_RESOURCES 0x14
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 22b253750f78..445829cd363c 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -121,7 +121,7 @@ static void hci_reject_sco(struct hci_conn *conn)
{
struct hci_cp_reject_sync_conn_req cp;

- cp.reason = HCI_ERROR_REMOTE_USER_TERM;
+ cp.reason = HCI_ERROR_REJ_LIMITED_RESOURCES;
bacpy(&cp.bdaddr, &conn->dst);

hci_send_cmd(conn->hdev, HCI_OP_REJECT_SYNC_CONN_REQ, sizeof(cp), &cp);
--
1.9.3



2014-09-24 12:05:09

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: Fix reason code used for rejecting SCO connections

Hi Johan,

> The core specification defines valid values for the
> HCI_Reject_Synchronous_Connection_Request command to be 0x0D-0x0F. So
> far the code has been using HCI_ERROR_REMOTE_USER_TERM (0x13) which is
> not a valid value and is therefore being rejected by some controllers:
>
>> HCI Event: Connect Request (0x04) plen 10
> bdaddr 40:6F:2A:6A:E5:E0 class 0x000000 type eSCO
> < HCI Command: Reject Synchronous Connection (0x01|0x002a) plen 7
> bdaddr 40:6F:2A:6A:E5:E0 reason 0x13
> Reason: Remote User Terminated Connection
>> HCI Event: Command Status (0x0f) plen 4
> Reject Synchronous Connection (0x01|0x002a) status 0x12 ncmd 1
> Error: Invalid HCI Command Parameters
>
> This patch introduces a new define for a value from the valid range
> (0x0d == Connection Rejected Due To Limited Resources) and uses it
> instead for rejecting incoming connections.
>
> Signed-off-by: Johan Hedberg <[email protected]>
> ---
> include/net/bluetooth/hci.h | 1 +
> net/bluetooth/hci_conn.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


2016-09-08 15:57:21

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: Fix reason code used for rejecting SCO connections

Hi Fred,

> A comment in the code states that SCO connection should be rejected
> with the proper error value between 0xd-0xf. The code uses
> HCI_ERROR_REMOTE_LOW_RESOURCES which is 0x14.
>
> This led to following error:
> < HCI Command: Reject Synchronous Co.. (0x01|0x002a) plen 7
> Address: 34:51:C9:EF:02:CA (Apple, Inc.)
> Reason: Remote Device Terminated due to Low Resources (0x14)
>> HCI Event: Command Status (0x0f) plen 4
> Reject Synchronous Connection Request (0x01|0x002a) ncmd 1
> Status: Invalid HCI Command Parameters (0x12)
>
> Instead make use of HCI_ERROR_REJ_LIMITED_RESOURCES which is 0xd.
>
> Signed-off-by: Frédéric Dalleau <[email protected]>
> ---
> net/bluetooth/hci_request.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


2016-09-08 10:05:46

by Frédéric Dalleau

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: Fix reason code used for rejecting SCO connections

Hi,

On 08/09/2016 12:00, Frédéric Dalleau wrote:
> A comment in the code states that SCO connection should be rejected
> with the proper error value between 0xd-0xf. The code uses
> HCI_ERROR_REMOTE_LOW_RESOURCES which is 0x14.

I borrowed the title from a previous patch was already doing that

http://permalink.gmane.org/gmane.linux.bluez.kernel/53456

BR,
Fred