Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2617663rdg; Mon, 16 Oct 2023 09:31:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMrHIqNNDq9xRNG7boM/kLyHa5q2AveJ2uKqSaOLPU0I0oJ87Bskg1jeZ5Mn2IbGSd7+Bk X-Received: by 2002:a05:6358:910:b0:13a:bd3:3f85 with SMTP id r16-20020a056358091000b0013a0bd33f85mr40332906rwi.23.1697473862020; Mon, 16 Oct 2023 09:31:02 -0700 (PDT) Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bv67-20020a632e46000000b005acba4c9bf4si7061965pgb.2.2023.10.16.09.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:31:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=fail header.i=@iki.fi header.s=lahtoruutu header.b=F7avvPVd; arc=fail (signature failed); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D7A6B8043C0C; Mon, 16 Oct 2023 09:30:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229501AbjJPQap (ORCPT + 99 others); Mon, 16 Oct 2023 12:30:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjJPQao (ORCPT ); Mon, 16 Oct 2023 12:30:44 -0400 Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62BB3A7 for ; Mon, 16 Oct 2023 09:30:42 -0700 (PDT) Received: from [192.168.1.195] (unknown [IPv6:2a02:ed04:3581:4::d001]) (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@iki.fi) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4S8Mzh0KWBz49Q5M; Mon, 16 Oct 2023 19:30:37 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1697473840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=OsKNQlpQtmU3xGG7JR8xhonyPmRIJ+7uDQq/7OZwVlQ=; b=F7avvPVdniyDmo3rlZII5dtZfgDA04uthURUY3kUG4dh03sLPUrXIg7RTzRoSu8p+Aotpz 4G+o/FnKvksZHzcQNF9SY6tpYkxO0ukLWdRffwcSZeGlbcN/FXNcTZpHzpdxuA/9MnSWa3 rUtrF10k0IWkq67srwkS7csdJA8TqwtXsx506AoIbW7l4BqWVUeF31BVwl3YqYXzI9HKab ysFhmgby7yL5fvj+x6fKaKDN8Iia3UvmPU5S4/ddmHUAMnKpnuodADgwlFrntGS9tcJtXe oY6LAS9oliLQRCJcLxjfi+N1EG460vsIiw+potVY5Hrdb1DLuDCvmv96lLYh4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1697473840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=OsKNQlpQtmU3xGG7JR8xhonyPmRIJ+7uDQq/7OZwVlQ=; b=eD9PwqeqSUpQiV9aQ+Mkb9HN85Q441vjd2aA3yAAsYdQNNsLCl4NvisCT8hJ2W0wNbiD9j onEb+ImoKFyQk4Rybo1+L5zALsA0uEcvme3WMkZvKH6tleRUwDL9m4tGm+xa1yXI7n5sTZ 6SgJA95R7Nn3xMndU2i7G1p8oJUS9dE6QhwZ+zmeuo53HQpkAw8J1rk1iozyu4xMqWKHPc fsJzRxn9QX84YWTk1WA6yNhwn4ndTXeCnAFdhY6Vxyo385J5kvClIHUovDc8wJ4Xu4m280 iOJwlbgFqfV9RSyXlm+PHP+t2dsf34T354ZWPNggiooBfDJXIDm1Wj/BnPy5TA== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1697473840; a=rsa-sha256; cv=none; b=i6rsnfGk8Dh7YFMc6oQEBjp1I8BMC/LU9DvU+AHOjw2pfzjtqPJOIFs077P6ECJ1+KgquP WA61Z0qtFyjTouHj7pIdP0bLlOrJf2z2/L6p3RcoxfeZDvb1Lp1PzADBKVGg55xRHL3NKy ngmVi/iyTH9rL+rb43qdsitdjQp+mK7WEJP/ZrQQqntdgduH0GKYHirJpJThlRl1Qv0dK4 0NKJBnZHvgspaxY6HYPJTa8YvO7pjIVuhtM2w5DYRqryNXM3o/5PplY4M26nNujYvCFrBv tyx+QnU+B6eBOd593jU1AYE8QLrnF1KH0BLCkkuObTi2VWZ/gEQkQ/269SPheQ== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav@iki.fi smtp.mailfrom=pav@iki.fi Message-ID: Subject: Re: [PATCH 1/1] Bluetooth: ISO: Allow binding a PA sync socket From: Pauli Virtanen To: Iulia Tanasescu , linux-bluetooth@vger.kernel.org Date: Mon, 16 Oct 2023 19:30:36 +0300 In-Reply-To: <20231016154545.2883-2-iulia.tanasescu@nxp.com> References: <20231016154545.2883-1-iulia.tanasescu@nxp.com> <20231016154545.2883-2-iulia.tanasescu@n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BX7YphlpKKv6UGiL0QuwWtXALrbI4EVbnozes89CaZHeE6zx/aDQgKa4ajInkIIvtOBmRqbvTPkJjcH84o7b84rP10DSO2Q2ooP8WYQ85y9RkF00yndR01VwNnURt7XmjVuoy8el0WUMv0q7evGTWSmXDPtUMq8e5DKt1uHWdkjV3uhHXjUTlI2gdMrxzbzxPYIWVWg4eE9jEdQvvGaYhDfFpmqF/ZSQT9jUCuWXMMpscy8NrmHnJtTvHBEfmaSgOQPnI7D7AA62q6mAVWEjcfKpgEs0Z2SK75P5yHmD2yEdZy+wSD8zheY1YDqvL50rx+l3mqoONmBwiW7R5dkMInqgQ156Uf8yMc8vv5exARr8WhJV61R2mSeHfxTFMMXaFG//NTHNX7ZpP0tECyePbu+IB32oa7P45EoNRZnLDG2KDOFsoUuy+CzQYPku5Gz8aqcgP7k8wb4J3QPPfiaAYrRJ9XOoiLUDodnWnPW9zLA1yWMnarzilEFPVmBztx6JKxlbFxnOfO6u5ry+uXZC4w= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.0 (3.50.0-1.fc39) MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:30:57 -0700 (PDT) Hi, ma, 2023-10-16 kello 18:45 +0300, Iulia Tanasescu kirjoitti: > This makes it possible to bind a PA sync socket to a number of BISes > before issuing the BIG Create Sync command. >=20 > Signed-off-by: Iulia Tanasescu > --- > net/bluetooth/iso.c | 41 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) >=20 > diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c > index 07b80e97aead..6938ff4accb3 100644 > --- a/net/bluetooth/iso.c > +++ b/net/bluetooth/iso.c > @@ -813,6 +813,40 @@ static int iso_sock_bind_bc(struct socket *sock, str= uct sockaddr *addr, > return 0; > } > =20 > +static int iso_sock_bind_pa_sk(struct sock *sk, struct sockaddr_iso *sa, > + int addr_len) > +{ > + int err =3D 0; > + > + lock_sock(sk); > + > + if (sk->sk_type !=3D SOCK_SEQPACKET) { > + err =3D -EINVAL; > + goto done; > + } > + > + if (addr_len <=3D sizeof(*sa)) { > + err =3D -EINVAL; > + goto done; > + } > + > + iso_pi(sk)->bc_num_bis =3D sa->iso_bc->bc_num_bis; > + > + for (int i =3D 0; i < iso_pi(sk)->bc_num_bis; i++) > + if (sa->iso_bc->bc_bis[i] < 0x01 || > + sa->iso_bc->bc_bis[i] > 0x1f) { > + err =3D -EINVAL; > + goto done; > + } > + > + memcpy(iso_pi(sk)->bc_bis, sa->iso_bc->bc_bis, > + iso_pi(sk)->bc_num_bis); > + > +done: > + release_sock(sk); > + return err; > +} > + > static int iso_sock_bind(struct socket *sock, struct sockaddr *addr, > int addr_len) > { > @@ -826,6 +860,13 @@ static int iso_sock_bind(struct socket *sock, struct= sockaddr *addr, > addr->sa_family !=3D AF_BLUETOOTH) > return -EINVAL; > =20 > + /* Allow the user to bind a PA sync socket to a number > + * of BISes to sync to. > + */ > + if (sk->sk_state =3D=3D BT_CONNECT2 && > + test_bit(BT_SK_PA_SYNC, &iso_pi(sk)->flags)) > + return iso_sock_bind_pa_sk(sk, sa, addr_len); > + > lock_sock(sk); If there's no reason not to, could we do instead lock_sock(sk); if (sk->sk_state =3D=3D BT_CONNECT2 && test_bit(BT_SK_PA_SYNC, &iso_pi(sk)->flags)) { err =3D iso_sock_bind_pa_sk(sk, sa, addr_len); goto done; } so that we don't race between branching on sk->sk_state and then taking the lock.=C2=A0iso_sock_bind_pa_sk wouldn't also need to do locking then. > =20 > if (sk->sk_state !=3D BT_OPEN) { --=20 Pauli Virtanen