Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp1048932rwe; Fri, 14 Apr 2023 13:30:36 -0700 (PDT) X-Google-Smtp-Source: AKy350bqL7QF56uYZDd98TOFUde9dLRL44W7iTNEgLAU2obkP031c1sLdsq/C8Q5C/iJRt6dIbyp X-Received: by 2002:a05:6a00:181f:b0:63b:7280:8a98 with SMTP id y31-20020a056a00181f00b0063b72808a98mr3042043pfa.17.1681504236360; Fri, 14 Apr 2023 13:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681504236; cv=none; d=google.com; s=arc-20160816; b=rbuOaTe9n9RduHtq19RjBIXjUeBUcbRIRMAw38yhr9I7e+UXNd5JeaXRd/CiMWeliN PfYSqs1gT5p6o9C/8B2KVwGtU9m/huT0tupr3fTkKTUuRR3LWQJ5i9GGGC4A8+x4h3Gm som3EQ/9YXrN3tlgZqhshfdZPn4JV94XSX89zqSaICN35RDuIy5CbU/s9hgWjuZFpEeR IruUjKCmIS/1aIOEF1wWvMX/0mM9vnZ4usxnSHR8BRjWTNCU8gMe/K5L++Yjt8Ymfk5g aACzDXoau0dBVUK2a/kFWIQSOaxJ2MHTkPxe7p08t7aq3tq9wsGpoLxOE6WjREVGJZC+ IE6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=zWcziJQrkYN9usLsUKPem8LL97aKOFRRa9P2n9/sR00=; b=yQ0iy83tdISU8U2ZhkLDALvQp4DiAUF+xECq2/HKihHzaGCMzCTc8ZBhiwB4mC8Syu iPBw7i7soXkuYVJcXTa4G7sAXV/7j85b6T4h2PTJq0wxBnpkoMz9EBQPxKaPfbF3CDBF 15tUtztYAl4VOwN4mMZVSWzbn4rZPC58IxSu9VWvIEjzJxT3MblE8bwFGtsnPEyw8yee Tz5b5VvFOB8c0p7PPKsT/bxIaPGXYcxnzajxCRycJv0h9eepTWbAEbhdDWMAB/Tc+KaO E8RJykiFVvtwyyrCcQaCHZq3D8m+qboLEH+ep/BTxWBuH3bhj4gGZ0SrGm8yD3hJ1+qQ TfjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="p/K/ngzT"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r24-20020a635158000000b0050bf0f1b79csi5433033pgl.699.2023.04.14.13.30.16; Fri, 14 Apr 2023 13:30:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="p/K/ngzT"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229784AbjDNU0P (ORCPT + 99 others); Fri, 14 Apr 2023 16:26:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbjDNU0O (ORCPT ); Fri, 14 Apr 2023 16:26:14 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53EDD6A6F for ; Fri, 14 Apr 2023 13:26:13 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id lh8so6516888plb.1 for ; Fri, 14 Apr 2023 13:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681503972; x=1684095972; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=zWcziJQrkYN9usLsUKPem8LL97aKOFRRa9P2n9/sR00=; b=p/K/ngzTmL6kRiNIydtyuaueR+qGtzaFMa6g27mR9MM7JGoErW+KjscMgg2oHvcAQi ueyfXQLPqHOR6hYkvIsSY0bKWtmlXCOkorof7oNqAJkruZwH8sNcV5kQiXPM7Gp0IJht pPUjhgUEyy9ThyNp4uLHIitK6CZBnMnv+JMr4RWkF3N7kz83AIpjPUQjsVSLN9JB6cFY m12PSkySnqsY4YMSzDAEIDfMrdMF3HYbFjLsNHCGI5GosPlTxIOMtZAvTBHpcM7K5Sbf qm+AUUzufIu9skQhs4sDBF2y3dHJOiosFvCEsLHEjbbxWZIAl6XsydNyHY0IZACKditY +kmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681503972; x=1684095972; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zWcziJQrkYN9usLsUKPem8LL97aKOFRRa9P2n9/sR00=; b=dWIkGInfltsSvww6DgOE0fAISSFbH4sujiI01eUMRLiGQIgtYj5WkHrOiMUfBhHHYZ qX5+cNftCYNOESiya393DPlnDxRktoLWGJEZmbe9YReO9dbi1D37oiTwRTSFjuMQjbcy 6z6wiV7Gwm09RYVqllzRUPtgkUFtgm09e/8p1R3ktVqM56rMqf4xXRYVc3dWAAeeAaHX +ozwuSfq/1GXldvHSKJE1HIZPJJ3XowjHkfG8ItgXJvU9BKz5MmrXbZ/EJby0fJLcRwp MIZ6O901tORthWzpgD0E+hjtBUvyaETpUOy2q+v1dWBo9aFtMrIpCCnX6M79U3envqj/ cYow== X-Gm-Message-State: AAQBX9e+g3zFuQJQcpa26pZGosbghz/GjtocDV4/lHcr+AB/DtBochdY nkUsvoVPMwBAunknD1kt+uLSv16xKJA= X-Received: by 2002:a05:6a20:2008:b0:d9:6c3d:29cf with SMTP id w8-20020a056a20200800b000d96c3d29cfmr6810871pzw.52.1681503971992; Fri, 14 Apr 2023 13:26:11 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id b16-20020aa78110000000b0062dedfd3d73sm3482453pfi.95.2023.04.14.13.26.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 13:26:11 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH v3 2/3] Bluetooth: hci_conn: Fix not matching by CIS ID Date: Fri, 14 Apr 2023 13:26:07 -0700 Message-Id: <20230414202608.1152970-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414202608.1152970-1-luiz.dentz@gmail.com> References: <20230414202608.1152970-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This fixes only matching CIS by address which prevents creating new hcon if upper layer is requesting a specific CIS ID. Signed-off-by: Luiz Augusto von Dentz --- include/net/bluetooth/hci_core.h | 12 +++++++++++- net/bluetooth/hci_conn.c | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 4fe1e71cb9d8..a6c8aee2f256 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1180,7 +1180,9 @@ static inline struct hci_conn *hci_conn_hash_lookup_le(struct hci_dev *hdev, static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev, bdaddr_t *ba, - __u8 ba_type) + __u8 ba_type, + __u8 cig, + __u8 id) { struct hci_conn_hash *h = &hdev->conn_hash; struct hci_conn *c; @@ -1191,6 +1193,14 @@ static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev, if (c->type != ISO_LINK) continue; + /* Match CIG ID if set */ + if (cig != BT_ISO_QOS_CIG_UNSET && cig != c->iso_qos.ucast.cig) + continue; + + /* Match CIS ID if set */ + if (id != BT_ISO_QOS_CIS_UNSET && id != c->iso_qos.ucast.cis) + continue; + if (ba_type == c->dst_type && !bacmp(&c->dst, ba)) { rcu_read_unlock(); return c; diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index d8466abbb36a..c215e983e287 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1841,7 +1841,8 @@ struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst, { struct hci_conn *cis; - cis = hci_conn_hash_lookup_cis(hdev, dst, dst_type); + cis = hci_conn_hash_lookup_cis(hdev, dst, dst_type, qos->ucast.cig, + qos->ucast.cis); if (!cis) { cis = hci_conn_add(hdev, ISO_LINK, dst, HCI_ROLE_MASTER); if (!cis) -- 2.39.2