Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3842765rdg; Wed, 18 Oct 2023 07:36:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHphJU2qYxhcCcgQgSfHXBo3i4VAEKBe0z+LoRHiDdOHQ0w45QprCghJaD184tcc2J8qJ9E X-Received: by 2002:a05:6a20:a319:b0:13d:1d14:6693 with SMTP id x25-20020a056a20a31900b0013d1d146693mr4295737pzk.45.1697639818082; Wed, 18 Oct 2023 07:36:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697639818; cv=pass; d=google.com; s=arc-20160816; b=j1ZizI9YYMtQSF36kL796lJBglFrrUiIMzQqh+H4WDJr0oOPr/6dyLcFR8KiIVl6Y6 tWOQQV8XPsQdsFr4X25cxBUqATKxbkdP6ctfCCVKD/uPCLhZJvh0fdamM5OlM6U78Nf9 DVVRhPmpV2t8+edQ+XtOrSfmAA7Zw/MTB7NDIGHz6TiZTxdwJCGXRAph4etPBZZqJr/O 0JalZaRf8/QkD9WCAH43FhgkqFgkpl/6J464PRCtbQ15EUzracJnhuXBU7zAqHqRzHs7 HsVkvzTVpP76Tucpiy40qhK4/ola1eDAC30MrreY1WqeEgFXc2/Q8wfuEuvBLwhXKMOs 20HA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hFkr+pPiyeqZAkLDBvthNj+ogr7ZqLB68pfSKy/Prpc=; fh=gOZmdXQWWYi2KI/CDlaL8bHElbVrtxjT8kPXxzTdvp8=; b=h5zxFOxplqr/71P5wJQwnD6CXhKA8gfLHGoxX8M/yJ5itAhFY+FQvEq7g5gv4KgC91 sjkQAgGHKrJF+JYnvb4IHHOVfPkB/TGB5MinFfnReYzm2FFS1Vx5079dIffgl1p1Ucg0 6q6k3p6mI5vjkvuEax6YjSn8GYpKFe8l01hdYVGVOcx/6+q4OyBjJOdxjrRSXgN3Kyiz fkHu4AR1Bk9qQUoBvbFf7ViwEjq3a5wmPt57CmE50Ntja4YTbL1zU8YgPCdNVy1ZfW1O TWYazlDXZMjzV9mcMnCyG32KKFfF2JhSwVBMQYuglBeTiYY0rDL3rsaMIxuQNLOGjjG2 Hs1g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=I8xdnPIB; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u11-20020a170902e80b00b001c7388413besi2248689plg.529.2023.10.18.07.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 07:36:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=I8xdnPIB; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4E7D980C1117; Wed, 18 Oct 2023 07:36:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235349AbjJROgv (ORCPT + 99 others); Wed, 18 Oct 2023 10:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345206AbjJROgh (ORCPT ); Wed, 18 Oct 2023 10:36:37 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2085.outbound.protection.outlook.com [40.107.6.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9B7D1BE4 for ; Wed, 18 Oct 2023 07:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JquHwv4otipxjfG5znAgGxDqLxpe2teQyAWGJnBLpOuxBxC4HLTcheh8ToDuEP5LrhhmoS5mynKP/I0jdIlpNPD7krxrLOi5bgEkbgDxeiZq8iAprYVL5Bqd6OIwZ42xcLD+nJ0lIFVx2sBt/zaPkASrYZ4Y99EAbOusXN1dto8CR0EAf1EmPMwQ/f2nNZ5iKX/bK2bL8sOlcdFRbOzTSOyXO87UFAhJRkT83yCaquQ97NsIjQR2m+pZhfhwg2hZNerXSfUgRQbM/3tZ43rZ1lnxwRlixiHa/0K+0IkzpiB97CkXDxbMzwoL8vSioh8L89ansP8UOKW1Em27ZRGUSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hFkr+pPiyeqZAkLDBvthNj+ogr7ZqLB68pfSKy/Prpc=; b=OEAIYDBkTGQse62Ea+yta/Gujs9bPd55pqtwgCVyH14TFFW+md0ASFe3jSzmr6j0vDlEfJRHGFVmMLV5RzWg8TYy62X2qFXBInPF78EAOLuks7dDSwxcwNtQa+XZ6kWBj6lH2QuI2zSOjDm5RMHJ1qxGDjPnCSjVsLM9bO1v+VBE5c63yw95XjjMv66l2Pb+w2J45nGbte7O1PSmbtsG83nWkNoUah4oYv+I5pytWXN5C45lNCR75SO+jup4eNyJbM0MCyI42RFdtTdnbtwqSd3l/g+qm5c2/Nles5Lc4dJMbXdWaeIY1uYSithVL4ULrscKuWdYGzSl2wgCGalfoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hFkr+pPiyeqZAkLDBvthNj+ogr7ZqLB68pfSKy/Prpc=; b=I8xdnPIBPFh17sMqgjK7tUKucIOylbEJdOWCXbWO6lM/0rJ0UQp1IVVA5uPAge35XeiNmIZpC3HXMEpKPUgis39KE7MdLBdcYBcqdQYDTW8+4vL0g6auKyjdekc8nol8jCIvzHJgNm1GixRtTSj32idkiTcSnnGVghRuDqdkP2k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DBAPR04MB7270.eurprd04.prod.outlook.com (2603:10a6:10:1af::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.7; Wed, 18 Oct 2023 14:34:47 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::7763:779b:1a89:47da]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::7763:779b:1a89:47da%3]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 14:34:47 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH v2 1/1] Bluetooth: ISO: Allow binding a PA sync socket Date: Wed, 18 Oct 2023 17:34:35 +0300 Message-Id: <20231018143435.3388-2-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231018143435.3388-1-iulia.tanasescu@nxp.com> References: <20231018143435.3388-1-iulia.tanasescu@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: VI1P190CA0046.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:1bb::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DBAPR04MB7270:EE_ X-MS-Office365-Filtering-Correlation-Id: cc18ddc8-a66c-432b-816b-08dbcfe760dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NF+vzHpXTuf1p6hWpYX4TsgA4/LUv8MpsRIaBi/F29M7/8h/oqxPNPmKree7ntBF8RqJk/3aHL23ywNcdkWvcta0yeQW2TecnX1MHqYZLcTqGHFPhh6g//tg7GzKiDA6sUaMXDN7wy7u53drk/MwzKBJodJR44ZurNc+PsjpfSNGmlJ++OWYRockfEGuvtQAxqLO5A3zWbV97vOfCkKdPwMNHXhuYMEP+XoUOUXqXtQ5MORRZ6AjbOgDEoakVx6Cwu4ZjPK6y3qvZC4M3Nj9q6bFm3dDGUbuNxuA338bbwuTQSc9LrwmSBLCRfwGzPHuiqY3vilebYbjaIiN2yyUbWXKP8krcVwrelf755ix40ydY7Bhd05qHobRAQ78H4OPBSRqIUZUs0OPIJ7G3btfGHAkl9fdoL1ahQjOb9ofXGZXn3ODokgOjjD3OUGQgsJIrP/n4dGyQ44ZpMqgp2C5a+VUEc7F4Rto5a2tQRecB0+W8FNaDEzAIF1nAPcoVO+KnGJsBllt7BBOzFL0Mxkzz5/FXodPEzZZ4mQWt6DY4ATqqmxe2l7rJfbIAfkSpVvE X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8898.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(39860400002)(136003)(376002)(346002)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(2906002)(44832011)(5660300002)(36756003)(8936002)(86362001)(8676002)(4326008)(83380400001)(38100700002)(26005)(1076003)(2616005)(6506007)(6666004)(316002)(478600001)(6916009)(6512007)(6486002)(66476007)(41300700001)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?yVeNaB0gSIGaaVzp1yPMYLSohPKnBnpuavxxIGk7g5AIOXQ2W/4pYv5C1/WJ?= =?us-ascii?Q?ujWlgngSrfBy5ZG7HLEOkBLBTxfHcV+KO/V0qy4iOYBeXZj6Ct2SZGVGJV/b?= =?us-ascii?Q?okibM5J8n+9NdZnyppplShr6He5MgGibMNV/ah412knkI5/do/CeNF0XRIrx?= =?us-ascii?Q?qLAjX3TrkI8q37Au43ZlhPsCsx38bdNfnY1SrRf+wCWtRGErqh/7pYurwc34?= =?us-ascii?Q?NzsyX5RAC3voVxzA+QBQOympqbza3oJ9HmWGXEe7lRwi2jpgVQwl3VZEzBXu?= =?us-ascii?Q?koPQ2OX9wDENw4NuSYxhusaciY6PMQydnQMexKsvRb2b+G1KgOZLJnetbGS3?= =?us-ascii?Q?oLjYnaKAWvfSoC1HSgVf50LFkbpf7nknbiLiHFxdRNWr9cOH2xlTGyGOYzX5?= =?us-ascii?Q?txd3vD/r6wM82AneyK2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Iv/e?= =?us-ascii?Q?QLiEENxq1QvQoKBJHJ0Bc+NQmi/o8gLV1fHWc0fcxSIc9RHlhYzUQm1LOyeS?= =?us-ascii?Q?CQYehOy0sJWeERpLlFrfLQ2r73wwLbtjVHT/PQ+JeHqxEg9OTPJFZ+C0x6sD?= =?us-ascii?Q?GzXC2Geq8fQkIMd/t+h+ofplYhfqBvcPXi3wYZ9yws5EjdEkjU8u+uDh6rtx?= =?us-ascii?Q?2QniR1PRaD2Xnjn36fP4pDASa6kKGwBeeQ9hDFZdAUSm5S3WLdjQxhuw9+22?= =?us-ascii?Q?QPRyGrG/8ZTwhCI/WA0UuHIPX1zogTfVWMF9V0ZX71kM83Hfa/M1hps7i67/?= =?us-ascii?Q?bQ=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc18ddc8-a66c-432b-816b-08dbcfe760dc X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 14:34:47.3733 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XBS5tIesXzKIT0/RZp5TvXHLaFuYNkus+bRe5hjbx+8o6+Y+IEoLP47VdnGa6/A3QKOtjYWgh+XT9Qzjc+DBTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7270 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 18 Oct 2023 07:36:56 -0700 (PDT) This makes it possible to bind a PA sync socket to a number of BISes before issuing the BIG Create Sync command. Signed-off-by: Iulia Tanasescu --- net/bluetooth/iso.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index 07b80e97aead..f20238c4702f 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -813,6 +813,37 @@ static int iso_sock_bind_bc(struct socket *sock, struct sockaddr *addr, return 0; } +static int iso_sock_bind_pa_sk(struct sock *sk, struct sockaddr_iso *sa, + int addr_len) +{ + int err = 0; + + if (sk->sk_type != SOCK_SEQPACKET) { + err = -EINVAL; + goto done; + } + + if (addr_len <= sizeof(*sa)) { + err = -EINVAL; + goto done; + } + + iso_pi(sk)->bc_num_bis = sa->iso_bc->bc_num_bis; + + for (int i = 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 = -EINVAL; + goto done; + } + + memcpy(iso_pi(sk)->bc_bis, sa->iso_bc->bc_bis, + iso_pi(sk)->bc_num_bis); + +done: + return err; +} + static int iso_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len) { @@ -828,6 +859,15 @@ static int iso_sock_bind(struct socket *sock, struct sockaddr *addr, lock_sock(sk); + /* Allow the user to bind a PA sync socket to a number + * of BISes to sync to. + */ + if (sk->sk_state == BT_CONNECT2 && + test_bit(BT_SK_PA_SYNC, &iso_pi(sk)->flags)) { + err = iso_sock_bind_pa_sk(sk, sa, addr_len); + goto done; + } + if (sk->sk_state != BT_OPEN) { err = -EBADFD; goto done; -- 2.39.2