Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1559699rwb; Wed, 26 Jul 2023 14:43:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlHMCqbNjp+Ct2Qtscat3zhtEfeuTB7ewGR29U08P8eX/hmcVYp2zhxQbGqUc9S/3Ng31OU5 X-Received: by 2002:a05:6a00:9a0:b0:682:4ef7:9b0b with SMTP id u32-20020a056a0009a000b006824ef79b0bmr4541079pfg.0.1690407796412; Wed, 26 Jul 2023 14:43:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1690407796; cv=pass; d=google.com; s=arc-20160816; b=eYodpsvAuiOYGM53Lb81YMB09OEgFhYGcMctLxY+5fxtsL7X8IbbcnGIYt2xtvAXba db8eE7bX/18R5kaWAbBM0w3WSbPcFgnwH7lrp2UI5NPzvqcjCWD4m0i7jurwiIAhOtNw r5UKm+7Kq9SVtHmwHNasaHeBizTlrCgW16pZP3DxG+hz3PTcsZXW3E/NaN+xgqETkX+W 22yy1yLhWDKc4DhpV5wBKEsLrEC6OVVWS3eiyQZrovYTCS5rHAhIAGHUrbpwDmSrQ9vV k4LuRSnxL577Qymje2vOZb7dfHb+EZG5o6nnQCqbqbiKHE9GQBbbxdyxvTnzttBxTYhH vRdQ== ARC-Message-Signature: i=2; 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 :dkim-signature; bh=wY79wLmp/mbU+avRSt0aj3qMsw6uaa1fo1QqQOAfhG4=; fh=raBgKoRsHCwQLc6ReOhmOoEQ+DtSaNc74fugaHBwryI=; b=t8bcSiRDlXncRst8rJdSilM9gjr2VUHmCNTR2QvhV9LolxVf03hNFbd9roFX0CbHfC g49IMdqyP5AVmLn88zaEwAe5LiLoIAOQI8Qfkc4VP+0uP8FhM805hjgmmy4vC5WtztAF MG44dOKOO0nXHvnIorSp9Uny2Vcu3XA5+vpi7tpQnb4NTmhjEF8rrWlbE5zz8tPdIgmh WYxoTPVs39hVrhLwwUgUn05SeLD4OLPFA6W4BV7bHGw2+Fue2edi8xnoGBsv9WZthypn me6W/8G56J1RQvgYh3+iE+A37EdKj9y8Qw77EwYdy9t0vcnpvp4ePvV/O8tsdqGSgPYl 2Dqg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=meesny header.b=pY1mp0fj; arc=pass (i=1); 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 bu3-20020a056a00410300b006687ed7b4a5si115995pfb.140.2023.07.26.14.43.00; Wed, 26 Jul 2023 14:43:16 -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=@iki.fi header.s=meesny header.b=pY1mp0fj; arc=pass (i=1); 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 S231545AbjGZV0J (ORCPT + 99 others); Wed, 26 Jul 2023 17:26:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231550AbjGZV0I (ORCPT ); Wed, 26 Jul 2023 17:26:08 -0400 Received: from meesny.iki.fi (meesny.iki.fi [IPv6:2001:67c:2b0:1c1::201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CD552691 for ; Wed, 26 Jul 2023 14:26:03 -0700 (PDT) Received: from monolith.lan (91-152-120-101.elisa-laajakaista.fi [91.152.120.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by meesny.iki.fi (Postfix) with ESMTPSA id 4RB6Q20W7xz1097; Thu, 27 Jul 2023 00:25:46 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1690406746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wY79wLmp/mbU+avRSt0aj3qMsw6uaa1fo1QqQOAfhG4=; b=pY1mp0fjF1Xcol9Py+W3bVDl+MCGXwWJUAzINIZKSCDamX/fqOifGJaoicozA7MDuHrgRF lSCvBvIR/tJy1fNpvrfhFQxGp5tlISVWFfcYMPsDwmq49Z0MVZgUydxbkTR/2RDMB3iRR3 adPugtQdiK85MA3FuWV+xtj6ya2nDw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1690406746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wY79wLmp/mbU+avRSt0aj3qMsw6uaa1fo1QqQOAfhG4=; b=KNooRWsdtR23rd36tJ9Di8qTFIC6Bd4Jm0ouZnGYh/VY1MLlZ04+UEnIvhyoziWV7Hmck4 78lPN55vWpjwklI51aZbTZlAZgX4C20/NiCY7TBwQnFNCiMxI1+L/Z5E7SWgn0OGzeFOtb i9fOf20TtFTQcdlLwFzJ/yIV+9t9JaY= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1690406746; a=rsa-sha256; cv=none; b=W/V7dIXFraEOTGx86/Ff0TkybY5VcDo4vvnoP79MN35NZUneg9okazKh+aQB+Sk3HytwJD nTXbBYEwRsNiMm+bPFjuIKbKjUZjOqvl5kIJfAC7vAZkX0omTwmGm3T/ZAaCn3tePAsE/T IzLnIce9NypSxAnMIzMSwjjkuq8296Y= From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH RFC 5/6] Bluetooth: hci_sync: delete CIS in BT_OPEN/CONNECT/BOUND when aborting Date: Thu, 27 Jul 2023 00:25:25 +0300 Message-ID: <6d9672c9a1e97b87e823e05ff07576013683979d.1690399379.git.pav@iki.fi> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 Dropped CIS that are in state BT_OPEN/BT_BOUND, and in state BT_CONNECT with HCI_CONN_CREATE_CIS unset, should be cleaned up immediately. Closing CIS ISO sockets should result to the hci_conn be deleted, so that potentially pending CIG removal can run. hci_abort_conn cannot refer to them by handle, since their handle is still unset if Set CIG Parameters has not yet completed. This fixes CIS not being terminated if the socket is shut down immediately after connection, so that the hci_abort_conn runs before Set CIG Parameters completes. See new BlueZ test "ISO Connect Close - Success" Signed-off-by: Pauli Virtanen --- net/bluetooth/hci_sync.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 101548fe81da..3926213c29e6 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -5339,6 +5339,10 @@ static int hci_connect_cancel_sync(struct hci_dev *hdev, struct hci_conn *conn, if (test_bit(HCI_CONN_CREATE_CIS, &conn->flags)) return hci_disconnect_sync(hdev, conn, reason); + /* CIS with no Create CIS sent have nothing to cancel */ + if (bacmp(&conn->dst, BDADDR_ANY)) + return HCI_ERROR_LOCAL_HOST_TERM; + /* There is no way to cancel a BIS without terminating the BIG * which is done later on connection cleanup. */ @@ -5426,9 +5430,17 @@ int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason) case BT_CONNECT2: return hci_reject_conn_sync(hdev, conn, reason); case BT_OPEN: - /* Cleanup bises that failed to be established */ - if (test_and_clear_bit(HCI_CONN_BIG_SYNC_FAILED, &conn->flags)) + /* Cleanup failed CIS, and BIS that failed to be established */ + if (bacmp(&conn->dst, BDADDR_ANY) || + test_and_clear_bit(HCI_CONN_BIG_SYNC_FAILED, &conn->flags)) + hci_conn_failed(conn, reason); + break; + case BT_BOUND: + /* Bound CIS should be cleaned up */ + if (conn->type == ISO_LINK && bacmp(&conn->dst, BDADDR_ANY)) hci_conn_failed(conn, reason); + else + conn->state = BT_CLOSED; break; default: conn->state = BT_CLOSED; -- 2.41.0