Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2230202rwd; Sun, 28 May 2023 10:47:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7AksUqxbnp1Pljyo1wao5F0SsEnFkGOqccgtglmHQgz4oJkVOPpR2vBp4rI7uCrG3fQy1f X-Received: by 2002:a17:902:ecc2:b0:1ac:750e:33d6 with SMTP id a2-20020a170902ecc200b001ac750e33d6mr6558069plh.23.1685296038345; Sun, 28 May 2023 10:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685296038; cv=none; d=google.com; s=arc-20160816; b=Q1+N411uIQXtUqcSFAwHGNwjHlFrl7FH53Emf3s0lPV6Duit0D0FtiaREe0dUuhGL3 XjN0j9+mQQ4TM7FCIBF1PO8BcYNm+m8/29v+BOHmWllRiSKRHsGTcAhnk4H/94EVV+g2 wskYnxsYA2ai7i2A5c8eqaQCzac5Py3Ar8vej3fbHejSW5iOTGoOAw5ObMoGgOiML3uS Jx/SBLiQz5YTZ1IyXHIq1K9iLPMH8fXdgz3LnngnumrS6YcH+S+yeRWTfpcrsyCXHt40 hZn6IWuLIxfqQa/0V4n/wtZpAnY9eUKkX4wbU6BsyrxyH99rg65JEycnW1iabG9IhGrn pd9w== 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:cc:to:from; bh=w6r/8EQt66qftpT0tdZON+o24i6Qdvt5z74NB1g3pZA=; b=HyRzlu+px0OH508c/JHvH9aeDSpVinKmK6YBle1uxaiOUtvOmq7rVY5TtLwA98Kf3e 5S90g1U+nqbkYIMr4EFpwGVATkS4QpCqFd0SG0QPlf9jn/lwvCz4Z4GpiLzhcMRTStLT YVb5RlGbvQopsx92+YJ8X0XsUinauu3deXJct92bX17kG6YpYMDtnKRk3NKpaBhKbLL4 LYaZe9cYC5svjnTfv9Z8v3uDj2Xe5tN0CWaq91KZlt7cn7iHLsNd4kCzrM7/8sjtl29R 4XJLGPyzoaPw5CSjHDvKMArjgAbbrinqOnT4kNPgJMBoCT4GiQSQu66x7MuEu/bu4q63 VdDA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a170902edd000b001b027afdef5si3290386plk.231.2023.05.28.10.47.04; Sun, 28 May 2023 10:47:18 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbjE1Rjg (ORCPT + 99 others); Sun, 28 May 2023 13:39:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjE1Rje (ORCPT ); Sun, 28 May 2023 13:39:34 -0400 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA85E4 for ; Sun, 28 May 2023 10:39:21 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id F0051240029 for ; Sun, 28 May 2023 19:39:18 +0200 (CEST) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QTm9y4Cz8z6txq; Sun, 28 May 2023 19:39:18 +0200 (CEST) From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ 2/4] btdev: fix inactive CIG configurable status Date: Sun, 28 May 2023 17:39:14 +0000 Message-Id: <1788d43df1a572539158d133f8d330e36340d7fe.1685283364.git.pav@iki.fi> In-Reply-To: <502997002ac9d4a76593aa4ba8237b7fb803c701.1685283364.git.pav@iki.fi> References: <502997002ac9d4a76593aa4ba8237b7fb803c701.1685283364.git.pav@iki.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NEUTRAL,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 CIG shall not be configurable after the first Create CIS until Remove CIG is issued (Core v5.3 Vol 6 Part B Sec. 4.5.14.3). We currently have it configurable in the inactive state (Create CIS done and all CIS closed), which is incorrect. Track CIG state and allow reconfigure only in nonexistent/configured state, i.e., when no CIS have been created yet. --- emulator/btdev.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index f9260511a..98d7af99e 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -105,6 +105,7 @@ struct le_ext_adv { struct le_cig { struct bt_hci_cmd_le_set_cig_params params; struct bt_hci_cis_params cis[CIS_SIZE]; + bool activated; } __attribute__ ((packed)); struct btdev { @@ -5864,29 +5865,24 @@ static int cmd_set_cig_params(struct btdev *dev, const void *data, goto done; } + /* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E + * page 2553 + * + * If the Host issues this command when the CIG is not in the + * configurable state, the Controller shall return the error + * code Command Disallowed (0x0C). + */ + if (dev->le_cig[cig_idx].activated) { + rsp.params.status = BT_HCI_ERR_COMMAND_DISALLOWED; + goto done; + } + rsp.params.status = BT_HCI_ERR_SUCCESS; rsp.params.cig_id = cmd->cig_id; for (i = 0; i < cmd->num_cis; i++) { - struct btdev_conn *iso; - rsp.params.num_handles++; rsp.handle[i] = cpu_to_le16(make_cis_handle(cig_idx, i)); - - /* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E - * page 2553 - * - * If the Host issues this command when the CIG is not in the - * configurable state, the Controller shall return the error - * code Command Disallowed (0x0C). - */ - iso = queue_find(dev->conns, match_handle, - UINT_TO_PTR(le16_to_cpu(rsp.handle[i]))); - if (iso) { - rsp.params.status = BT_HCI_ERR_COMMAND_DISALLOWED; - i = 0; - goto done; - } } memcpy(&dev->le_cig[cig_idx], data, len); @@ -6006,6 +6002,8 @@ static int cmd_create_cis_complete(struct btdev *dev, const void *data, evt.cig_id = le_cig->params.cig_id; evt.cis_id = le_cig->cis[cis_idx].cis_id; + le_cig->activated = true; + le_meta_event(iso->link->dev, BT_HCI_EVT_LE_CIS_REQ, &evt, sizeof(evt)); } -- 2.40.1