2023-02-25 00:21:05

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH 1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list

From: Luiz Augusto von Dentz <[email protected]>

This makes hci_conn_hash_add append to the tail of the conn_hash so it
matches the order they are created, this is required if the controller
attempts to match the order of ACL with CIS which uses append logic
when programming the CIS ids on the CIG.

The result of this change affects Create CIS:

From:

< HCI Command: LE Create Connected Isochronous Stream (0x08|0x0064) plen 9
Number of CIS: 2
CIS Handle: 2560
ACL Handle: 3586
CIS Handle: 2561
ACL Handle: 3585

To:

< HCI Command: LE Create Connected Isochronous Stream (0x08|0x0064) plen 9
Number of CIS: 2
CIS Handle: 2560
ACL Handle: 3585
CIS Handle: 2561
ACL Handle: 3586

Signed-off-by: Luiz Augusto von Dentz <[email protected]>
---
include/net/bluetooth/hci_core.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 7254edfba4c9..9488671c1219 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -978,7 +978,7 @@ static inline bool hci_conn_sc_enabled(struct hci_conn *conn)
static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
{
struct hci_conn_hash *h = &hdev->conn_hash;
- list_add_rcu(&c->list, &h->list);
+ list_add_tail_rcu(&c->list, &h->list);
switch (c->type) {
case ACL_LINK:
h->acl_num++;
--
2.37.3



2023-02-25 00:21:06

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH 2/3] Bluetooth: hci_core: Detect if an ACL packet is in fact an ISO packet

From: Luiz Augusto von Dentz <[email protected]>

Because some transports don't have a dedicated type for ISO packets
(see 14202eff214e1e941fefa0366d4c3bc4b1a0d500) they may use ACL type
when in fact they are ISO packets.

In the past this was left for the driver to detect such thing but it
creates a problem when using the likes of btproxy when used by a VM as
the host would not be aware of the connection the guest is doing it
won't be able to detect such behavior, so this make bt_recv_frame
detect when it happens as it is the common interface to all drivers
including guest VMs.

Fixes: 14202eff214e ("Bluetooth: btusb: Detect if an ACL packet is in fact an ISO packet")
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
---
net/bluetooth/hci_core.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b65c3aabcd53..334e308451f5 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2871,10 +2871,25 @@ int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
return -ENXIO;
}

- if (hci_skb_pkt_type(skb) != HCI_EVENT_PKT &&
- hci_skb_pkt_type(skb) != HCI_ACLDATA_PKT &&
- hci_skb_pkt_type(skb) != HCI_SCODATA_PKT &&
- hci_skb_pkt_type(skb) != HCI_ISODATA_PKT) {
+ switch (hci_skb_pkt_type(skb)) {
+ case HCI_EVENT_PKT:
+ break;
+ case HCI_ACLDATA_PKT:
+ /* Detect if ISO packet has been sent as ACL */
+ if (hci_conn_num(hdev, ISO_LINK)) {
+ __u16 handle = __le16_to_cpu(hci_acl_hdr(skb)->handle);
+ __u8 type;
+
+ type = hci_conn_lookup_type(hdev, hci_handle(handle));
+ if (type == ISO_LINK)
+ hci_skb_pkt_type(skb) = HCI_ISODATA_PKT;
+ }
+ break;
+ case HCI_SCODATA_PKT:
+ break;
+ case HCI_ISODATA_PKT:
+ break;
+ default:
kfree_skb(skb);
return -EINVAL;
}
--
2.37.3


2023-02-25 00:21:06

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH 3/3] Bluetooth: btusb: Remove detection of ISO packets over bulk

From: Luiz Augusto von Dentz <[email protected]>

This removes the code introduced by
14202eff214e1e941fefa0366d4c3bc4b1a0d500 as hci_recv_frame is now able
to detect ACL packets that are in fact ISO packets.

Fixes: 14202eff214e ("Bluetooth: btusb: Detect if an ACL packet is in fact an ISO packet")
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
---
drivers/bluetooth/btusb.c | 10 ----------
1 file changed, 10 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 6273a93defd2..4ca91c033d2f 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1050,21 +1050,11 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)
hci_skb_expect(skb) -= len;

if (skb->len == HCI_ACL_HDR_SIZE) {
- __u16 handle = __le16_to_cpu(hci_acl_hdr(skb)->handle);
__le16 dlen = hci_acl_hdr(skb)->dlen;
- __u8 type;

/* Complete ACL header */
hci_skb_expect(skb) = __le16_to_cpu(dlen);

- /* Detect if ISO packet has been sent over bulk */
- if (hci_conn_num(data->hdev, ISO_LINK)) {
- type = hci_conn_lookup_type(data->hdev,
- hci_handle(handle));
- if (type == ISO_LINK)
- hci_skb_pkt_type(skb) = HCI_ISODATA_PKT;
- }
-
if (skb_tailroom(skb) < hci_skb_expect(skb)) {
kfree_skb(skb);
skb = NULL;
--
2.37.3


2023-02-25 01:19:43

by bluez.test.bot

[permalink] [raw]
Subject: RE: [1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list

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/project/bluetooth/list/?series=724805

---Test result---

Test Summary:
CheckPatch FAIL 1.96 seconds
GitLint PASS 0.79 seconds
SubjectPrefix PASS 0.26 seconds
BuildKernel PASS 31.97 seconds
CheckAllWarning PASS 34.63 seconds
CheckSparse PASS 39.41 seconds
CheckSmatch PASS 109.16 seconds
BuildKernel32 PASS 30.46 seconds
TestRunnerSetup PASS 439.59 seconds
TestRunner_l2cap-tester PASS 15.85 seconds
TestRunner_iso-tester PASS 16.80 seconds
TestRunner_bnep-tester PASS 5.43 seconds
TestRunner_mgmt-tester PASS 108.45 seconds
TestRunner_rfcomm-tester PASS 8.63 seconds
TestRunner_sco-tester PASS 7.96 seconds
TestRunner_ioctl-tester PASS 9.26 seconds
TestRunner_mesh-tester PASS 6.87 seconds
TestRunner_smp-tester PASS 7.79 seconds
TestRunner_userchan-tester PASS 5.65 seconds
IncrementalBuild PASS 38.78 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list
WARNING: Use a single space after To:
#98:
To:

ERROR: Unrecognized email address: ''
#98:
To:

ERROR: Missing Signed-off-by: line by nominal patch author ''

total: 2 errors, 1 warnings, 8 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13151871.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.




---
Regards,
Linux Bluetooth

2023-02-27 21:40:23

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH 1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list

Hello:

This series was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Fri, 24 Feb 2023 16:20:50 -0800 you wrote:
> From: Luiz Augusto von Dentz <[email protected]>
>
> This makes hci_conn_hash_add append to the tail of the conn_hash so it
> matches the order they are created, this is required if the controller
> attempts to match the order of ACL with CIS which uses append logic
> when programming the CIS ids on the CIG.
>
> [...]

Here is the summary with links:
- [1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list
https://git.kernel.org/bluetooth/bluetooth-next/c/c25cd4779f1b
- [2/3] Bluetooth: hci_core: Detect if an ACL packet is in fact an ISO packet
https://git.kernel.org/bluetooth/bluetooth-next/c/8c999e405d6b
- [3/3] Bluetooth: btusb: Remove detection of ISO packets over bulk
https://git.kernel.org/bluetooth/bluetooth-next/c/e574898ac6ae

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html